3
votes

I want to create admin interface for existing model User.

What is the simplest way?
I think, it's scaffolding.

Scaffolding in rails is generated by script(rails generate scaffold), and there is no options to do it dynamically (like in django), correct?

So how can I create scaffolding controller AdminUsers for model User? Create AdminUsers scaffolding and replace AdminUser model by User?

What should I do if model will be changed by migrations? Manually update scaffolding controller and views, right? Is there any automation?

3
have you looked into ActiveAdmin?kobaltz
No, I didn't know about it. Now I'm reading its documentation. I think it's that what I need.Dmitry

3 Answers

5
votes

You can generate the files dynamically using scaffolding- the scaffold command can take a namespaced argument.

rails generate scaffold Admin::User

You don't need another model though- your Admin::UsersController and views should be working with the User model.

5
votes

Using standard solutions such as activeadmin or rails_admin is the simpliest way. If you want something custom and still wondering how to scaffold controller AdminUsers for model User, you might want to take a look at rails-admin-scaffold gem which automates this process and an article with more detailed explanation.

0
votes

enter image description here

ActiveAdmin is a neat user interface for your Rails application. It gives you a fully customizable user interface to your models.

Site: http://activeadmin.info/

Demo: http://demo.activeadmin.info/admin

Railscasts Episode: http://railscasts.com/episodes/284-active-admin