Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Application Admin Section

I am working on my first Rails application and want to create an admin section.

Do I want to keep my views and controllers completely separate (that is, in separate directories) for the admin section and the rest of the site?

How can I organize my views/controllers in custom directories (how do I configure the routing)?

like image 311
GeekJock Avatar asked Mar 28 '09 05:03

GeekJock


1 Answers

To create your admin controllers:

script/generate controller admin/articles

Then in your routes.rb file

map.resource :admin do |admin|
  admin.resources :articles, :path_prefix => "admin", :name_prefix => "admin_", :controller => "admin/articles"
end

You could then access the index url for this:

<%= link_to "Articles Admin", admin_articles_path %>
like image 138
nitecoder Avatar answered Sep 20 '22 00:09

nitecoder