I have a user model that can have one album. Album can have multiple
photos. How do I create nested resources for these three models? How
do you avoid nesting more than two levels?
All the examples I have seen only have nesting with two levels. TIA.
On 7/1/07, [email protected] [email protected] wrote:
I have a user model that can have one album. Album can have multiple
photos. How do I create nested resources for these three models? How
do you avoid nesting more than two levels?
All the examples I have seen only have nesting with two levels. TIA.
You can nest as deeply as you want.
–
Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com
I have:
map.resources :users do |user|
user.resource :album do |album|
album.resources :photos
end
end
Should I use the singular resource for my case?Thanks.
[email protected] wrote:
I have:
map.resources :users do |user|
user.resource :album do |album|
album.resources :photos
end
end
Should I use the singular resource for my case?Thanks.
From the ri documentation for “resource”:
See map.resources for general conventions. These are the main
differences:
- a singular name is given to map.resource. The default
controller name is taken from the singular name.
- To specify a custom plural name, use the :plural option. There
is no :singular option
- No default index, new, or create routes are created for the
singleton resource controller.
- When nesting singleton resources, only the singular name is
used as the path prefix (example: ‘account/messages/1’)