Lost in translation - Rails 2.0 Nested Resources, Custom Actions

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.

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 [email protected] 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.
http://www.frozenplague.net

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?

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?

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 [email protected] wrote:

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

{ :publish => :put } </?>

Thanks in advance.


Ryan B.http://www.frozenplague.net


Ryan B.
http://www.frozenplague.net

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs