Most apps have an admin interface, a place where the developers and special users can make changes to the database.
Creating your own admin interface is time-consuming, and can take the focus away from developing user-facing features. Figuring that admin interfaces have similar needs, frameworks have emerged that help get your started.
With Rails Admin, you can edit your database on dev and production, in a user-friendly way, without coding your own admin interface.
Its closest competition is Active Admin, which I see as too complex for a convenience tool.
Add this to your Gemfile:
In a terminal window, while inside the path of your app, run
rails g rails_admin:install
You now have an admin panel, located at http://yourapp.com/admin
Two essential steps remain.
One, make sure your models are defined correctly. Have you defined associations, like belongs_to, has_one, and has_many, as needed?
Two, restrict access to your admin interface. tell Rails Admin who should be allowed access.
How it looks
My app will deliver online courses. So far, it contains two tables:
Each component falls under a lesson. In Rails-speak, a component :has_one lesson, and one lesson :has_many components.
Rails Admin looks at my models and shows them in its left navigation. I never had to separately tell Rails Admin the structure of my database.
When I click on a table, I see its records.
I can edit records. Since components are related to lessons, I can add components to lessons and associate each component to a lesson, all within Rails Admin.
Rails Admin can help you launch faster by removing the need to develop your own custom admin interface.
At the start, either use a quick solution like Rails Admin or create your own custom admin interface. You can always move from Rails Admin to a custom interface later.
This is the beginning of a new series, Up and Running. We’ll tell you how to get up and running with several developer tools, quickly and easily. Get updates about what we cover next.