Trouble in Rails 3 Adding Restful Routes to Namespaced Resources
I am trying to add a route to a controller that has been set as a resource开发者_Python百科 in the 'admin' namespace like this:
namespace :admin do
resources :books do
collection do
post :process_new
end
end
end
I have added an action int the Admin::BooksController for process_new, but whenever I try to access this action using the url: .../admin/books/process_new I get the following error:
Couldn't find Book with ID=process_new
It looks like it's routing to the show action and trying to use process_new as the id. Can someone shed some light on what I may be doing wrong?
**Edit: I changed my redirects to use the helper functions and it seems to be working.
Add get :process_new
to your resources :books routes:
namespace :admin do
resources :books do
collection do
get :process_new
post :process_new
end
end
end
精彩评论