I created a search and replace controller, with just an index action. Since it's meant to go under one of my restful controllers created by a scaffold, i setup the following in the routes file:
resources :sites do
resource :search_and_replace, only: [:index]
end
However, it does not appear when 开发者_StackOverflow中文版I run rake routes. If I switch to resources, it does. But the method name is site_search_and_replace_index
. The pluralization of resource doesn't feel right either, since this is not around multiple records in a table.
The index
action doesn't exist in a singular resource. This makes sense if you think of the meaning of the action: index of what, there's only one resource? Use show
instead:
resources :sites do
resource :search_and_replace, only: [:show]
end
Are you sure you want to have search and replace as a resource? There might be other options that are more useful: Adding more restful actions
精彩评论