I am new to the routing scheme for RESTful actions on the edge. I am trying to stray off of the CRUD path a little here and finding the terrain a little bumpy. I am trying to call the method TopicsController#toggle_lock. Topics belong to Forums, so we have this structure in the routes.rb: map.resources :forums do |forum| forum.resources :topics do |topic| topic.resources :posts topic.resources :member => { :toggle_lock => :get } end end when I try to hit http://localhost/forums/1/topics/5;toggle_lock I get a 404. What am I doing wrong? What is the best way to test this stuff? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Got it to work! map.resources :forums do |forum| forum.resources :topics do |topic| topic.resources :posts end forum.resources :topics, :member => { :toggle_lock => :post } end And since there aren''t any examples out there with tests, here is my test: def test_should_toggle_lock login_as :aaron post :toggle_lock, :forum_id => forums(:comics).id, :id => topics(:galactus).id assert_redirected_to topic_path(forums(:comics), topics(:galactus)) assert_equal ''Topic has been locked.'', flash[:notice] end On 8/24/06, Carl Fyffe <carl.fyffe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am new to the routing scheme for RESTful actions on the edge. I am > trying to stray off of the CRUD path a little here and finding the > terrain a little bumpy. > > I am trying to call the method TopicsController#toggle_lock. Topics > belong to Forums, so we have this structure in the routes.rb: > > map.resources :forums do |forum| > forum.resources :topics do |topic| > topic.resources :posts > topic.resources :member => { :toggle_lock => :get } > end > end > > when I try to hit http://localhost/forums/1/topics/5;toggle_lock I get a 404. > > What am I doing wrong? > > What is the best way to test this stuff? >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Carl Fyffe wrote:> I am new to the routing scheme for RESTful actions on the edge. I am > trying to stray off of the CRUD path a little here and finding the > terrain a little bumpy. > > I am trying to call the method TopicsController#toggle_lock. Topics > belong to Forums, so we have this structure in the routes.rb: > > map.resources :forums do |forum| > forum.resources :topics do |topic| > topic.resources :posts > topic.resources :member => { :toggle_lock => :get } > end > end > > when I try to hit http://localhost/forums/1/topics/5;toggle_lock I get a > 404. > > What am I doing wrong?map.resources :forums do |forum| forum.resources :topics, :member => { :toggle_lock => :get } do |topic| topic.resources :posts end end> What is the best way to test this stuff?Get Rick "technoweenie" Olson''s routing_navigator plugin. script/plugin install routing_navigator -- Josh Susser http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you Josh! On 8/24/06, Josh Susser <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Carl Fyffe wrote: > > I am new to the routing scheme for RESTful actions on the edge. I am > > trying to stray off of the CRUD path a little here and finding the > > terrain a little bumpy. > > > > I am trying to call the method TopicsController#toggle_lock. Topics > > belong to Forums, so we have this structure in the routes.rb: > > > > map.resources :forums do |forum| > > forum.resources :topics do |topic| > > topic.resources :posts > > topic.resources :member => { :toggle_lock => :get } > > end > > end > > > > when I try to hit http://localhost/forums/1/topics/5;toggle_lock I get a > > 404. > > > > What am I doing wrong? > > map.resources :forums do |forum| > forum.resources :topics, :member => { :toggle_lock => :get } do > |topic| > topic.resources :posts > end > end > > > What is the best way to test this stuff? > > Get Rick "technoweenie" Olson''s routing_navigator plugin. > > script/plugin install routing_navigator > > -- > Josh Susser > http://blog.hasmanythrough.com > > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---