I have a Sinatra app and I want to use RailsAdmin as my admin engine with models in Sinatra app. How can I do that without having to duplicate the model code for RailsAdmin project
I don't think it can be easily done.
rails_admin relies on models being backed by ActiveModel, so you cannot feed it with your plain-ruby models.
You can try someting like this though https://github.com/ratnakarrao-nyros/sinatra-admin, but it doesn't look that well maintained.
Related
I'm new in Ruby on Rails, I'm wondering, is there a user interface to see all the data that you have in your Active Record Models and manipulate them just like PhpMyAdmin?
Sadly no - you have to write that interface yourself... :)
There are ways to quickly scaffold up an interface for each of your models. Look at doco on rails generate scaffold for more info.
There are also gems that will automate some admin-scaffolding for you:
Look at eg ActiveAdmin
But in practice nobody keeps either of these around for long in their projects (for various reasons).
If you're new to Rails, I can highly recommend reading your way through the Rails Guides here: http://guides.rubyonrails.org It will help you level up in all the fundamental aspects of Rails :)
There are gems in rails to maintain tables in rails app:
ActiveAdmin: It provides admin panel using which you can add/update/delete any record under tables.
rails_db_info: Just and it under Gemfile and run bundle install. Go to "/rails/info/db" link, it will list all tables with schema details. Its very easy to integrate.
I am building a rails app without a database.
In Disable ActiveRecord for Rails 4 I learned how to configure the app so that the absence of the database related gems does not interfere with running it. The problem is that I still want to create models using the commend rails generate mode MyModel.
Under this configuration, the above command does nothing at all.
I am assuming here I would need to require some modules (for example, activemodel, which seems to provide ActiveRecord-like capabilities without necessarily having a DB) in application.rb, but I can seem to find which.
Could someone help?
Thanks in advance
You can take a look at How to create custom generators for my rails app.
Basically you will have to change the behavior of your model generators. This way you can tell which file will be created, with which code template and etc.
So I've been reading tutorials and trying to understand the differences between a ruby gem, a rails engine and a rails plugin however it is not completely clear which path to take.
Say I wanted to make an extension to rails which needs access only to active record within rails.
Should I do this within a rails engine? It seems overkill since I won't be needing routes, controllers, or views just a way to create models which exist within a database. Or do I make a gem that requires rails be installed? and if I do go that route is it possible to have db migrations within the gem. What happens if I just require ActiveRecord? Will others still easily be able to integrate my gem within their own projects?
It would be nice to know that if I do make a gem it is not required that the users absolutely have to have the full rails stack within the application they are working on.
I have a set of models I need to share among several rails3/sinatra/etc applications. I haven't seen anything like this yet and I'm curious what is the most effective way to go about this in a DRY manner? Can I specify a central area for models, can I create a gem that only brings in the models I need? How have other people approached this issue. I was thinking of making a smallish gem or something I don't yet know about to handle this.
I'm using Datamapper, but this is also a more general issue of structuring multiple rails/non rails ruby apps.
You might find it's easier to have a submodule in your repository that contains your models and associated unit tests than to create a full-fledged gem. This way you can patch from one app to the other instead of having to drive everything top down.
You can create public API to models you want to use in other apps.
In rails you should already have REST controllers, so you can use ActiveResource in the other apps.
You can pack your ActiveResource classes in a gem just to simplify thing and to keep things DRY.
You can check: http://api.rubyonrails.org/classes/ActiveResource/Base.html for some examples.
And it doesn't matter if you're using ActiveRecord or DataMapper.
I recently switched to MongoDB and I am wondering if I can continue using any of the popular admin interface solutions, such as ActiveScaffold and Typus?
You can try Rails Admin:
a Rails engine that provides an easy-to-use interface for managing your data.
Features
CRUD any data with ease
Custom actions
Automatic form validation
Search and filtering
Export data to CSV/JSON/XML
Authentication (via Devise or other)
Authorization (via CanCanCan or Pundit)
User action history (via PaperTrail)
Supported ORMs
ActiveRecord
Mongoid
ActiveAdmin https://github.com/gregbell/active_admin is a great tool for the admin interface creation. And I believe sooner or later they add mongoid support.
Right now there's some patch for it: https://github.com/ebeigarts/mongoid_active_admin_app
I didn't try it myself though.
if your using Mongoid as your ORM, then active_admin should do the job.. apply this patch to get it working
this disables some functionalities (mostly filters because active_admin relies on meta_search and that gem only supports active_record)
Fixes ActiveAdmin sorting
Disables ActiveAdmin Filters/Search
Disables ActiveAdmin Comments
I think you'll find this page on MongoDB's site to be the best help:
http://www.mongodb.org/display/DOCS/Admin+UIs
There are many admin applications available, some in browser, some fat client, etc. that you can use for admin and maintaining your Mongo backend.
I am a .Net programmer so I have used only MongoVUE, but one that caught my eye that I might check out and it should be platform agnostic is JMongoBrowser
I'd bet plenty options will work with a RAILS setup.