Namespace with index action in Rails
I have an admin controller located inside /controllers/admin/admin_controller.rb I also have a pages controller located inside /controllers/admin/pages_controller.rb In my routes.rb file, I have the following:
map.namespace :admin do |admin|
admin.resources :pages
end
When the user goes to localhost:3000/admin, I'd like the user to see a page with a link to /admin/pages
(Pages CRUD) and to /
(To go back home). Since I am using a namespace, I cannot have an index action for /admin
. H开发者_高级运维ow would I get this done and still have my controllers located inside my /controllers/admin
folder (rather than using admin as a map.resources
component and a has_many
association to pages). Please note I am only interested in the show
action of admin.
You can have an index action for /admin:
map.namespace :admin do |admin|
admin.root :controller => "pages"
end
精彩评论