Problem with index action route on a resource with the same name in plural and singular forms
Reported by Drew Chandler | September 30th, 2008 @ 07:25 AM | in 0.9.8
I have a route for a resource like this:
Merb::Router.prepare do
identify :id do
resources :news
end
end
I can generate the url for the show action just fine using:
url(:news, @news)
but the index route throws a Generation Error.
url(:news) # causes Generation Error: Named route news could not be generated with {}
I am not sure if this is a bug or poor naming on my part(I could call the resource news_item instead). These routes were working under the old router.
Comments and changes to this ticket
-
Michael Klishin (antares) September 30th, 2008 @ 07:16 PM
- → Milestone changed from to 0.9.8
- → State changed from new to open
- → Assigned user changed from to Carl Lerche
-
Carl Lerche September 30th, 2008 @ 08:53 PM
- → State changed from open to resolved
There will be a problem with resources that have the same plural and singular names. The singular and plural have to be different in order to create separate entries in the route hash.
I added an option :singular that lets you set the singular name to something specific for times when the inflector can't figure it out.
Merb::Router.prepare do resources :news, :singular => :news_item # ... or something end url(:news) # => /news url(:news_item, 10) # => /news/10Hope this helps.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
