Rails_admin is very good, but often too much for what some people want. Developing your own admin section is quite simple.
How to create your own RESTful admin section with Rails 3.2
Create your own Admin section with CRUD for all models, including nested resources, using namespaces.
Example - admin section for a blog - Models: post, comment (attached message resource)
I assume you have a basic blog application. See http://guides.rubyonrails.org/getting_started.html to set it all up.
The first step is to create an administrator section and a controller
rails g controller admin/admin
This will create an empty controller from which all of our Admin controllers will inherit. And he will also create views / admin / admin / index.html.erb, which can act as a toolbar.
Creating Admin Controllers
rails g controller admin/posts rails g controller admin/comments
This will create an empty Admin :: PostsController and Admin :: CommentsController in the admin namespace
Step 2 - add a namespace for admin controllers Go to config / routes.rb and add the following
namespace :admin do root to: "admin#index" resources :posts do resources :comments, :only => [:create, :destroy] end end
Step 3 - Editing administrators and controllers files to work with the admin namespace Now we have everything we need to make working with the administrator controller, and not with the interface.
Change the inheritance of all Admin :: * controllers.
class Admin::PostsController < ApplicationController => class Admin::PostsController < Admin::AdminController
and
class Admin::CommentsController < ApplicationController => class Admin::CommentsController < Admin::AdminController
copy all templates from applications / views / messages to the application / views / admin / posts copy all templates from applications / views / comments to the application / views / admin / comments copy all functions from posts_controller.rb to admin / posts_controller.rb copy all functions from comment_controller.rb to admin / comments_controller.rb
Add a link to the views /admin/admin/index.html.erb for each model for which you would like to have an Admin CRUD controld. For example, mail.
<%= link_to "Posts", admin_posts_path %>
Edit admin / posts_controller.rb. Change 3 calls to redirect_to to work with the admin namespace. Ways to create and update:
redirect_to @post => redirect_to [:admin, @post]
Destruction Method:
redirect_to posts_url => redirect_to admin_posts_url
Make the same changes in all the templates so that they work inside the admin namespace. You need to make the following changes:
post / _form.html.erb:
form_for(@post) => form_for([:admin, @post])
post / edit.html.erb, index.html.erb, new.html.erb and show.html.erb find all instances:
<%= link_to 'Show', @post %> => <%= link_to 'Show', [:admin, @post] %> posts_path => admin_posts_path edit_post_path(@post) => edit_admin_post_path(@post) new_post_path => new_admin_post_path <%= render "comments/form" %> => <%= render "admin/comments/form" %>
comment / _comment.html.erb
<%= link_to 'Destroy Comment', [comment.post, comment],... => <%= link_to 'Destroy Comment', [:admin, comment.post, comment],...
comment / _form.html.erb change:
<%= form_for([@post, @post.comments.build]) do |f| %>=> <%= form_for([:admin, @post, @post.comments.build]) do |f| %>
That's all. Now you have a / admin control panel with a link to / admin / posts and available CRUD actions.
Go to http://icebergist.com/posts/restful-admin-namespaced-controller-using-scaffolding . His solution since 2008 is still very relevant, however, obviously, there are some differences from Rails 3.2 to which this answer refers; including invested resources.