You could create a separate top-level song resource to accomplish
this, e.g.,
map.resources :artists do |artist|
artist.resources :songs, :name_prefix => ''artist_''
end
map.resources :songs
This would create routes for a top-level song resource as well as your
original nested song resource. The top-level song resource will have
the usual route helpers. Because of the :name_prefix option, the route
helpers for the nested song resource will have "artist_" prepended to
their name to prevent them from conflicting with the top-level song
resource, e.g., artist_songs_path(X) => /artists/X/songs.
-John
On Jun 11, 12:05 pm, Sebastian Schön
<sch...-jQYb0UV0y0GqKhchLyddgg@public.gmane.org>
wrote:> Hi,
>
> I´ve problems with the restful routes.
>
> I know that /artists/1/songs works:
>
> map.resources :artists do | artists |
> artists.resources :songs
> end
>
> But how can I route to a list of all songs with artist, something
> like /songs ... in a restful manner.
>
> Thanks
> Sebastian
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---