Parker Thompson
2007-Jun-03 18:41 UTC
resource routes where singular and plural are the same
I have a question regarding routes for resources that have the same name in the singular and plural. For example, if I have: map.resources :series do |series| series.resources :characters end then ''new_series_url'' generates ''/series/new'', however I get the following error when I hit that url: series_url failed to generate from {:action=>"show", :controller=>"series"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["series", :id] - are they all satisifed? I''m presuming here it assumes I want the url for an existing series. I am able to create series if I use a singleton resource, e.g.: map.resources :series however, this fouls up the nesting of my characters resource causing ''new_character_url(:series_id => @series)'' to generate the following url: http://localhost:3000/series/characters/new?series_id=16 which makes some sense, as I''ve now said series is a singleton resource. So, my question is how do I disambiguate between series (plural) and series (singular) when using non-singleton resources and generated url helpers to get properly nested resources? Thanks, pt. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Trevor Squires
2007-Jun-04 02:27 UTC
Re: resource routes where singular and plural are the same
Hey, I explain how here: http://somethinglearned.com/articles/2007/03/19/how-to-uncountable-names-in-restful-routes HTH, Trevor On 6/3/07, Parker Thompson <parkert-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a question regarding routes for resources that have the same > name in the singular and plural. For example, if I have: > > map.resources :series do |series| > series.resources :characters > end > > then ''new_series_url'' generates ''/series/new'', however I get the > following error when I hit that url: > > series_url failed to generate from {:action=>"show", > :controller=>"series"} - you may have ambiguous routes, or you may > need to supply additional parameters for this route. content_url has > the following required parameters: ["series", :id] - are they all > satisifed? > > I''m presuming here it assumes I want the url for an existing series. > I am able to create series if I use a singleton resource, e.g.: > > map.resources :series > > however, this fouls up the nesting of my characters resource causing > ''new_character_url(:series_id => @series)'' to generate the following > url: > > http://localhost:3000/series/characters/new?series_id=16 > > which makes some sense, as I''ve now said series is a singleton > resource. So, my question is how do I disambiguate between series > (plural) and series (singular) when using non-singleton resources and > generated url helpers to get properly nested resources? > > Thanks, > > pt. > > > >-- -- Trevor Squires http://somethinglearned.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---