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)?
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 %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With