Forum: Ruby on Rails REST and nested resources more than one level?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
49eea5a820f17d9a5df2db047cbcdd72?d=identicon&s=25 sterling (Guest)
on 2007-04-02 21:49
(Received via mailing list)
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 Anderson
http://sterlinganderson.net/
sterling_anderson[at]mac.com
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-04-02 22:26
(Received via mailing list)
Don't see why not. Have you tried it and had problems?

Jason
E0e0e58f6ab7368839e9c606249f9b36?d=identicon&s=25 Nelson Hsu (nelson)
on 2007-04-03 01:33
Yes you can, but you may want to take a look at this link[1] which
suggests against doing so.

[1] http://weblog.jamisbuck.org/2007/2/5/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 Anderson
> http://sterlinganderson.net/
> sterling_anderson[at]mac.com
2a34c68022ae45d335c77b6ffc412a2f?d=identicon&s=25 Thomas Mango (Guest)
on 2007-04-03 20:39
(Received via mailing list)
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 Hsu <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.