Hello, I have a Hotel model and I mapped all routes for this class via map.resources. map.resources :hotels, :collection => { :search => :get, :cheapest => :get } I also mapped some additional actions including a search action and a cheapest actions that returns the list of hotels filtered with a specific algorithm. Now I need to implement a new feature for resolving some data conflict. The feature requires an action to display the conflict (HotelController#conflict => GET) and an other action for resolving the conflict (HotelController#resolve => PUT). Because I have 2 different actions with different http methods but basically related to the same feature, should I map the features using resource :member or should I use a classic #connect and switch between get/post checking request method within the action? map.conflict ''conflict'', :controller => ''hotel'', :action => ''conflict'' vs map.resources :hotels, :collection => { :search => :get, :cheapest => :get }, :member => { :conflict => :get, :resolve_conflict => :put } Is there a third option? I see the first one is the most used but usually only because the projects I used as examples were originally designed for Rails 1.2 without a real consideration of map.resource. Thanks, Simone --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 30, 2008, at 9:27 AM, Simone Carletti wrote:> Because I have 2 different actions with different http methods but > basically related to the same feature, should I map the features using > resource :member or should I use a classic #connect and switch between > get/post checking request method within the action? > > map.conflict ''conflict'', :controller => ''hotel'', :action => ''conflict'' > vs > map.resources :hotels, :collection => { :search => :get, :cheapest > => :get }, :member => { :conflict => :get, :resolve_conflict > => :put } > > Is there a third option? > > I see the first one is the most used but usually only because the > projects I used as examples were originally designed for Rails 1.2 > without a real consideration of map.resource. > > Thanks, > SimoneYou can add the restriction yourself: map.edit_account(''account/edit/:id'', :controller => ''account'', :action => ''update'', :conditions => { :method => :post }) map.edit_account(''account/edit/:id'', :controller => ''account'', :action => ''edit'', :conditions => { :method => :get }) Or in your case: map.conflict ''hotels/:id/conflict'', :controller => ''hotel'', :action => ''conflict'', :conditions => { :method => :get } map.conflict ''hotels/:id/conflict'', :controller => ''hotel'', :action => ''resolve_conflict'', :conditions => { :method => :post } -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Rob! Here http://github.com/bborn/communityengine/tree/master/routes.rb I found the following statement: resources :users, :member_path => ''/:id'', :nested_member_path => ''/:user_id'', :member => { ... :forgot_password => [:get, :post], } do |user| but it doesn''t work to me. It only seems to accepts a :post/:get/:delete/:put or :any. Do you know something more about this undocumented feature? Simone On May 30, 4:05 pm, Rob Biedenharn <R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org> wrote:> On May 30, 2008, at 9:27 AM, Simone Carletti wrote: > > > > > Because I have 2 different actions with different http methods but > > basically related to the same feature, should I map the features using > > resource :member or should I use a classic #connect and switch between > > get/post checking request method within the action? > > > map.conflict ''conflict'', :controller => ''hotel'', :action => ''conflict'' > > vs > > map.resources :hotels, :collection => { :search => :get, :cheapest > > => :get }, :member => { :conflict => :get, :resolve_conflict > > => :put } > > > Is there a third option? > > > I see the first one is the most used but usually only because the > > projects I used as examples were originally designed for Rails 1.2 > > without a real consideration of map.resource. > > > Thanks, > > Simone > > You can add the restriction yourself: > > map.edit_account(''account/edit/:id'', :controller => > ''account'', :action => ''update'', > :conditions => { :method => :post }) > map.edit_account(''account/edit/:id'', :controller => > ''account'', :action => ''edit'', > :conditions => { :method => :get }) > > Or in your case: > > map.conflict ''hotels/:id/conflict'', :controller => ''hotel'', :action => > ''conflict'', :conditions => { :method => :get } > map.conflict ''hotels/:id/conflict'', :controller => ''hotel'', :action => > ''resolve_conflict'', :conditions => { :method => :post } > > -Rob > > Rob Biedenharn http://agileconsultingllc.com > R...-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 30, 2008, at 4:55 PM, Simone Carletti wrote:> but it doesn''t work to me. > It only seems to accepts a :post/:get/:delete/:put or :any. Do you > know something more about this undocumented feature? > > SimoneNo, I think I found it by reading the source of the routing helpers (or the testing support for routes). I don''t recall whether I''d tried the [:get,:post] way and that failed or I just never needed to do that when routing to a single action. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---