I have a Rails route definition that looks something like this:
namespace :admin do
resources :feeds
resources :push
end
rake routes
generates the following output for it:
admin_feeds GET /admin/feeds {:controller=>"admin/feeds", :action=>"index"}
admin_push_index GET /admin/push {:controller=>"admin/push", :action=>"index"}
Why would would the path helper for push
get the _index
suffix, but not feeds
?
It's all based on the plurality of the resource. So if the resource name is plural, then it has no need to add an _index
suffix since it's inferred.
If it is a singular resource name, then it adds the suffix for clarification since admin_push
would typically be a show
action instead of the index
action.
You can also use
resource :push
instead of
resources :push
to specify a singular resource. See http://api.rubyonrails.org/classes/ActionDispatch/Routing.html
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