REST and nested resources more than one level?

Is it possible to nest a resource more than a single level? For
example something like this:

map.resources :articles do |article|
article.resources :comments do |comment|
comment.resources :foo
end
end


Sterling A.

sterling_anderson[at]mac.com

Don’t see why not. Have you tried it and had problems?

Jason

Yes you can, but you may want to take a look at this link[1] which
suggests against doing so.

[1] Buckblog: Nesting resources

Nelson

Basedex - A Collaborative Index to organize and collect everything
related to Ruby on Rails
http://blazingrails.basedex.com/index/8

sterling wrote:

Is it possible to nest a resource more than a single level? For
example something like this:

map.resources :articles do |article|
article.resources :comments do |comment|
comment.resources :foo
end
end


Sterling A.
http://sterlinganderson.net/
sterling_anderson[at]mac.com

The scenario explained in that article is pretty specific. There are
many instances where nesting further than a single level deep is
necessary. For example, if you were creating CRM system, you may have
a structure like:

map.resources :customers do |customers|
customers.resources :ships do |ships|
ships.resources :accounts
end
end

Here, each customer can have many shipping addresses and for each
shipping address there can be many ship accounts (ups, fedex, etc). In
addition, a shipping account is only associated with a single shipping
address and therefore should only be referenced through the shipping
address.

On Apr 2, 7:33 pm, Nelson H. [email protected]