I had this working yesterday, I don't know what I did to break it.
Here are the routes for a RESTful controller:
brand_responsibilities GET /brands/:brand_id/responsibilities(.:format) {:action=>"index", :controller=>"responsibilities"}
brand_responsibilities POST /brands/:brand_id/responsibilities(.:format) {:action=>"create", :controller=>"responsibilities"}
new_brand_responsibility GET /brands/:brand_id/responsibilities/new(.:format) {:action=>"new", :controller=>"responsibilities"}
edit_brand_responsibility GET /brands/:brand_id/responsibilities/:id/edit(.:format) {:action=>"edit", :controller=>"responsibilities"}
brand_responsibility GET /brands/:brand_id/responsibilities/:id(.:format) {:action=>"show", :controller=>"responsibilities"}
brand_responsibility PUT /brands/:brand_id/responsibilities/:id(.:format) {:action=>"update", :controller=>"responsibilities"}
brand_responsibility DELETE /brands/:brand_id/responsibilities/:id(.:format) {:action=>"destroy", :controller=>"responsibilities"}
My form looks like this:
<%= form_for :responsibility, :remote => true do |f| %>
<%= f.hidden_field :access_request_id, :value => ar.id %>
<%= f.hidden_field :user_id, :value => user.id %>
<%= f.hidden_field :brand_id, :value => @brand.id %>
<%= f.submit %>
<% end %>
But I get a 404 now with this log message:
Started POST "/brands/30/responsibilities" for 127.0.0.1 at Tue Oct 26 10:47:17 -0400 2010
ActionController::RoutingError (No route matches "/brands/30/responsibilities"):
It sure looks like the route matches to me! What am I missing?
Update: I also tried this in the console:
rs.recognize_path '/brands/30/responsibilities', :method => :post
and the response is:
=> {:controller=>"responsibilities", :brand_id=>"30", :action=>"create"}
What is my deal?
UPDATE #2:
I found the cause, though I don't know why it's the cause. I have another field:
<%= button_to "Deny", brand_responsibilities_path(@brand, :ar => ar), :remote => true, :method => :delete %>
That I was including in the form. I left it out for brevity's sake before because I didn't think it was important. I see that was a bad idea.
Does anybody know why the presence of that line in the form causes the weird routing error?