I posted this question last night but it doesn''t seem to have made it to the group. I''m wondering why I can''t get a post method to work for a custom action I''ve tried map.resources :foo, :collection => { :sort => :post} map.resources :foo, :new => { :sort => :post} map.resources :foo, :create => { :sort => :post} map.resources :foo, :member => { :sort => :post} In all cases the post call seems to take me to either the create action or show. Sorry if this is a really basic question but docs say you should be able to do :any and it''s not happening for me. Thanks. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Grayson Piercee wrote:> I posted this question last night but it doesn''t seem to have made it to > the group. > > I''m wondering why I can''t get a post method to work for a custom action > > I''ve tried > > map.resources :foo, :collection => { :sort => :post} > map.resources :foo, :new => { :sort => :post} > map.resources :foo, :create => { :sort => :post} > map.resources :foo, :member => { :sort => :post} > > In all cases the post call seems to take me to either the create action > or show. > > Sorry if this is a really basic question but docs say you should be able > to do :any and it''s not happening for me. > > Thanks.When you mean it doesn''t work, do you mean that your method in the controller doesn''t get dispatched to? In the future, when asking for help, please provide at least some details like the error message that you are getting, relevant log info, stack trace, etc,, Using this information, we can provide further assistance.. ilan -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Grayson Piercee wrote:> I''m wondering why I can''t get a post method to work for a custom actionDid you restart the application after changing your routes.rb file? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Based on what you''ve posted, my guess is that you want to return a set of sorted foos. If that''s the case, the first form is correct -- it''s an operation on the entire collection of foos. The form appears to be correct as well (action_id => HTTP Verb). The first question then is: did you restart your webrick/mongrel server? The routes file is only parsed when the server starts so you could have made the correct change and the server just did not know it. Next, you may need to look at how you invoked the call to the server. Forms default to POST and links often use a GET. Rails provides a :method option as part of its helpers so you can force the postback to use the right verb. link_to sort_foos_path, :method=>:post HTH, AndyV On Mar 2, 11:46 am, Grayson Piercee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I posted this question last night but it doesn''t seem to have made it to > the group. > > I''m wondering why I can''t get a post method to work for a custom action > > I''ve tried > > map.resources :foo, :collection => { :sort => :post} > map.resources :foo, :new => { :sort => :post} > map.resources :foo, :create => { :sort => :post} > map.resources :foo, :member => { :sort => :post} > > In all cases the post call seems to take me to either the create action > or show. > > Sorry if this is a really basic question but docs say you should be able > to do :any and it''s not happening for me. > > Thanks. > -- > Posted viahttp://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?hl=en -~----------~----~----~----~------~----~------~--~---