[I re-posted this ticket under 3.0RC]
There seems to be some issues with the routing for resources
under a namespace. I have tried this on both Rails 3b3 and 3b4 and
both failed:
View code:
<%= form_for @notebook, :url => toggle_app_notebook_path(@notebook), :remote => true do |form| %>
<%= submit_tag 'Toggle' %>
<% end %>
routes.rb:
namespace :app do
resources :notebooks do
member do
get :toggle # get always works
post :toggle # Post returns 404
end
end
end
rake routes generate this:
GET /app/notebooks/:id/toggle(.:format) {:controller=>"app/notebooks", :action=>"toggle"}
toggle_app_notebook POST /app/notebooks/:id/toggle(.:format) {:controller=>"app/notebooks", :action=>"toggle"}
While GET requests work as expected, the POST always failed with
a 404 error:
No route matches "/app/notebooks/1/toggle
To get this route to work correctly, I have to declare another
matcher outside the resources :notebooks but still under the
namespace, and the URL would be recognized correctly:
namespace :app do
match 'notebooks/:id/toggle' => 'notebooks#toggle'
resources :notebooks do
member do
get :toggle
post :toggle
end
end
end
I'm on ruby-1.8.7-p249
(edit 1: update formatting)