# Lost in translation - Rails 2.0 Nested Resources, Custom Actions

**URL:** <https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778>\
**Category:** Rails\
**Created:** [December 12, 2007, 3:40am UTC](https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778 "2007-12-12T03:40:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptontiger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@ptontiger](https://www.ruby-forum.com/u/ptontiger)\
**Post date:** [December 12, 2007, 3:40am UTC](https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778/1 "2007-12-12T03:40:01Z")

</div>

The shift to the :has\_many and :has\_one options when defining nested  
resource routes has me perplexed. The block format allows me to define  
custom REST actions like publish in the example below:

map.resources :users do |user|  
user.resources :articles, :member =\> { :publish =\> :put }  
end

It also allows for multiple levels of nesting if necessary.

What I’d really like to know is how do I enable custom REST actions  
for nested resources using the newer options technique?

map.resources :users, :has\_many =\> :articles # … \<?\> :member =\>  
{ :publish =\> :put } \</?\>

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ptontiger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@ptontiger](https://www.ruby-forum.com/u/ptontiger)\
**Post date:** [December 12, 2007, 3:54am UTC](https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778/2 "2007-12-12T03:54:38Z")

</div>

map.resources :users do |user|  
user.resources :articles, :member =\> { :publish =\> :put }  
end

seems to be the only way to do it at the moment.

On Dec 12, 2007 10:10 AM, ptontiger [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What I’d really like to know is how do I enable custom REST actions  
> for nested resources using the newer options technique?
> 
> map.resources :users, :has\_many =\> :articles # … \<?\> :member =\> { :publish =\> :put }
> 
> Thanks in advance.
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![ptontiger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@ptontiger](https://www.ruby-forum.com/u/ptontiger)\
**Post date:** [December 12, 2007, 3:56am UTC](https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778/3 "2007-12-12T03:56:23Z")

</div>

Thanks Ryan, that’s what I figured. That being the case, is the newer  
options definition slated to be a replacement for the block definition  
or will there continue to be coexistence?

---

<div class="post-metadata">

**Author:** ![ptontiger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@ptontiger](https://www.ruby-forum.com/u/ptontiger)\
**Post date:** [December 21, 2007, 5:29pm UTC](https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778/4 "2007-12-21T17:29:22Z")

</div>

I’m having similar frustrations.

map.resources :users, :has\_many =\> [:fingers], :has\_one =\> [:nose]  
map.resources :users do |users|  
users.resources :peepers, :controller =\> ‘eyes’ # So we can call  
eyes ‘peepers’ in the site URLs  
end

I have to use the old block format to specify a different controller  
name.

Any ideas?

---

<div class="post-metadata">

**Author:** ![ptontiger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@ptontiger](https://www.ruby-forum.com/u/ptontiger)\
**Post date:** [December 12, 2007, 4:30am UTC](https://www.ruby-forum.com/t/lost-in-translation-rails-2-0-nested-resources-custom-actions/122778/5 "2007-12-12T04:30:52Z")

</div>

At a guess there will continue to be co-existance. I guess the :has\_many  
and  
so on are only useful for when that related object has only the default  
7  
actions.

On Dec 12, 2007 10:52 AM, ptontiger [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > seems to be the only way to do it at the moment.
> > 
> > > { :publish =\> :put } \</?\>
> > 
> > > Thanks in advance.
> > 
> > –  
> > Ryan B.[http://www.frozenplague.net](http://www.frozenplague.net)

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!
