RESTful Resources and Sub-Resources

Quick question I’m hoping you guys might know…

I’m working at re-factoring my application to be RESTful and I’m
running into a lot of problems as I try to totally understand this
whole REST thing… my question here however is with the routes.rb
file… for example I have Clients, who have Locations… so would
the code in the routes.rb file be

map.resources :clients, :has_many => [ :locations ]

or I’ve seen this as well…

map.resources :clients do |clients|
clients.resources :locations
end

Which of these is the correct Rails 2.0 way of doing it?

Thanks in advanced.

Which of these is the correct Rails 2.0 way of doing it?

As far as I know both are valid, just the former being a shorthand for
default cases and the latter allowing for advanced configuration
parameters such as custom methods.

Cheers,
Jan

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