# Route #resource + member vs #connect

**URL:** <https://www.ruby-forum.com/t/route-resource-member-vs-connect/139061>\
**Category:** Rails\
**Created:** [May 30, 2008, 3:28pm UTC](https://www.ruby-forum.com/t/route-resource-member-vs-connect/139061 "2008-05-30T15:28:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![overclokkato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c67d28/32.png) [@overclokkato](https://www.ruby-forum.com/u/overclokkato)\
**Post date:** [May 30, 2008, 3:28pm UTC](https://www.ruby-forum.com/t/route-resource-member-vs-connect/139061/1 "2008-05-30T15:28:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![overclokkato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c67d28/32.png) [@overclokkato](https://www.ruby-forum.com/u/overclokkato)\
**Post date:** [May 30, 2008, 5:37pm UTC](https://www.ruby-forum.com/t/route-resource-member-vs-connect/139061/2 "2008-05-30T17:37:28Z")

</div>

On May 30, 2008, at 9:27 AM, Simone C. wrote:

> 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 B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![overclokkato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c67d28/32.png) [@overclokkato](https://www.ruby-forum.com/u/overclokkato)\
**Post date:** [May 30, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/route-resource-member-vs-connect/139061/3 "2008-05-30T22:56:13Z")

</div>

Thanks Rob!  
Here [http://github.com/bborn/communityengine/tree/master/routes.rb](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 B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![overclokkato](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c67d28/32.png) [@overclokkato](https://www.ruby-forum.com/u/overclokkato)\
**Post date:** [May 31, 2008, 1:18am UTC](https://www.ruby-forum.com/t/route-resource-member-vs-connect/139061/4 "2008-05-31T01:18:11Z")

</div>

On May 30, 2008, at 4:55 PM, Simone C. 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?
> 
> Simone

No, 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 B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
