Forum: Ruby on Rails resource routes where singular and plural are the same

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
19c9af375aca3001e3978cb16684803c?d=identicon&s=25 Parker Thompson (Guest)
on 2007-06-03 20:41
(Received via mailing list)
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.
27c170f482104299af279902be0a9c26?d=identicon&s=25 Trevor Squires (Guest)
on 2007-06-04 04:27
(Received via mailing list)
Hey,

I explain how here:

http://somethinglearned.com/articles/2007/03/19/ho...

HTH,
Trevor

On 6/3/07, Parker Thompson <parkert@gmail.com> wrote:
>
>
>
> Thanks,
>
> pt.
>
> >
>


--
--
Trevor Squires
http://somethinglearned.com
This topic is locked and can not be replied to.