Mikel Lindsaar
2007-Dec-28 05:58 UTC
Getting wrong route - fairly complete error description
OK, I have a routing problem, that seems to be working in the console,
but not in the app.
I have people that have nested tasks, like so:
-------------------------------
# routes.rb
map.resources :people do |person|
person.resources :phone_notes
person.resources :documents
person.resources :tasks, :member => {:complete => :put}
end
map.resources :tasks, :member => {:complete => :put}
-------------------------------
And then if I go into irb and try to recognize and generate those
routes, all is good:
------------------------------->> rs = ActionController::Routing::Routes
>> rs.recognize_path("/people/9/tasks/95/complete", :method
=> :put)
=> {:action=>"complete", :person_id=>"9",
:controller=>"tasks",
:id=>"95"}>> rs.generate({:action=>"update",
:person_id=>"9",
:controller=>"tasks", :id=>"95"})
=> "/people/9/tasks/95/complete"
-------------------------------
So that is all good.
Then rake routes gives me a list which also shows things are good:
-------------------------------
complete_person_task PUT /people/:person_id/tasks/:id/complete
{:controller => "tasks", :action => "complete"}
-------------------------------
But then in my people/show view I have:
-------------------------------
<%= button_to "Done", :url => complete_person_task_path(task),
:method
=> :put -%>
-------------------------------
Which generates this URL:
-------------------------------
http://127.0.0.1:3000/people/9?method=put&url=%2Fpeople%2F9%2Ftasks%2F95%2Fcomplete
-------------------------------
Which gives the following error:
-------------------------------
Unknown action
No action responded to 9003000000071902
-------------------------------
So obviously the route is not tagging on the custom nested route I have made.
So I disabled the "default" routes at the bottom and then I get:
-------------------------------
ActionController::MethodNotAllows
Only get, put, and delete requests are allowed
Request Parameters:
{"url"=>"/people/9/tasks/95/complete",
"method"=>"put" }
-------------------------------
Anyone got any ideas? I am sure it is something simple, but just
tearing my hair out on this one.
Regards
Mikel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Mikel Lindsaar
2007-Dec-28 06:00 UTC
Re: Getting wrong route - fairly complete error description
On Dec 28, 2007 4:58 PM, Mikel Lindsaar <raasdnil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Which gives the following error: > ------------------------------- > Unknown action > No action responded to 9003000000071902 > -------------------------------Obviously this 9003000000071902 is a mistake. Should be 9 which is the person ID. Don''t ask... cut and paste deamons Mikel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---