I have a question about what is regarded as good practice in the context of RESTful Rails interfaces. I have a Subscribers Controller with "index" and "new" (and other) actions. In routes.rb I define resource-based routing with "map.resources :subscribers". In my index view I have a button_to that points to "new_subscriber_path". Since the button generates a POST request, which doesn''t match any resource-based routes, I also have "map.connect '':controller/:action''" in routes.rb to ensure that the request goes to the intended "new"action. This does exactly what I want it to, but it seems a little awkward to have defined RESTful routes, and in this particular case to not use one because of a UI design choice I''ve made (a button instead of a link). Should this be viewed as a limitation in the way Rails supports REST, or is there a different way I should be doing this? Mark. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
MarkMT wrote:> In my index view I have a button_to that points to > "new_subscriber_path". Since the button generates a POST request, > which doesn''t match any resource-based routes, I also have > "map.connect '':controller/:action''" in routes.rb to ensure that the > request goes to the intended "new"action.button_to creates a form, and forms can GET. That is in fact what forms do by default, but rails specifies that they should be POST because that''s what most people probably want. Anyway, button_to "Foo", bar_path, :method => :get is the way to go, rather than adding routes like that. -- 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 -~----------~----~----~----~------~----~------~--~---
Thank you! Just what I needed to know! Mark. On Oct 16, 3:24 pm, August Lilleaas <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> MarkMT wrote: > > In my index view I have a button_to that points to > > "new_subscriber_path". Since the button generates a POST request, > > which doesn''t match any resource-based routes, I also have > > "map.connect '':controller/:action''" in routes.rb to ensure that the > > request goes to the intended "new"action. > > button_to creates a form, and forms can GET. That is in fact what forms > do by default, but rails specifies that they should be POST because > that''s what most people probably want. Anyway, button_to "Foo", > bar_path, :method => :get is the way to go, rather than adding routes > like that. > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---