OK, I have a routing problem, that seems to be working in the console, and with rake routes 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 9 ------------------------------- 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-31 02:20 UTC
Re: Rake routes & console showing one thing, app doing another
On Dec 29, 2007 10:21 AM, Mikel <raasdnil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> <%= button_to "Done", :url => complete_person_task_path(task), :method > => :put -%> > ------------------------------- > Unknown action > No action responded to 9 > ------------------------------- > Anyone got any ideas? I am sure it is something simple, but just > tearing my hair out on this one.The solution was simple, button_to doesn''t take :url => url, it just takes the "complete_person_task_path(task) as the item. so the button_to line becomes. <%= button_to "Done", complete_person_task_path(task), :method => :put %> Thanks to someone on IRC for finding this one. 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 -~----------~----~----~----~------~----~------~--~---