I am curious if the following URL pattern is appropriate to use with
REST and map.resources:
Let''s say I want to build a website with information about cars. I
decide that there will be a page to view/manage cars by model. The
route for this is easily created:
map.resources :cars
The URLs look great. But now I want to introduce the ability to
specify cars by year. I can do this by modifying the existing route:
map.resources :cars do |car|
car.resources :years
end
However, this leads to an undesirable URL pattern. To view a 1998
Corvette, I need to point my browser at /cars/corvette/years/1998.
What I wanted was /car/corvette/1998. In addition, the /car/corvette
URL would enumerate all years that the corvette was produced. I want a
POST request on /car/corvette to be used for adding new years.
Essentially, I want the ability to nest resources, without specifying
the nested resource name. I know how to do this without using the
resources API, so I''m not looking for a workaround.
In the CarsController, I would access a car with params[:id]. In the
CarYearsController, I would access a particular year of a car by using
params[:car] and params[:id]. (The :id would be the year). Is this
just a bad idea?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---