This project is archived and is in readonly mode.
Singular option unavailable in the new Routes
Reported by Rizwan Reza | April 2nd, 2010 @ 12:20 PM | in 3.0.2
In Rails 2.3:
map.resources :teeth, :singular => "tooth"
Generates the following:
GET /teeth(.:format) {:action=>"index", :controller=>"teeth"}
teeth POST /teeth(.:format) {:action=>"create", :controller=>"teeth"}
new_tooth GET /teeth/new(.:format) {:action=>"new", :controller=>"teeth"}
GET /teeth/:id(.:format) {:action=>"show", :controller=>"teeth"}
PUT /teeth/:id(.:format) {:action=>"update", :controller=>"teeth"}
tooth DELETE /teeth/:id(.:format) {:action=>"destroy", :controller=>"teeth"}
edit_tooth GET /teeth/:id/edit(.:format) {:action=>"edit", :controller=>"teeth"}
In Rails 3, passing :singular as an option generates the following:
GET /teeth(.:format) {:action=>"index", :singular=>"tooth", :controller=>"teeths"}
teeths POST /teeth(.:format) {:action=>"create", :singular=>"tooth", :controller=>"teeths"}
new_teeth GET /teeth/new(.:format) {:action=>"new", :singular=>"tooth", :controller=>"teeths"}
GET /teeth/:id(.:format) {:action=>"show", :singular=>"tooth", :controller=>"teeths"}
PUT /teeth/:id(.:format) {:action=>"update", :singular=>"tooth", :controller=>"teeths"}
teeth DELETE /teeth/:id(.:format) {:action=>"destroy", :singular=>"tooth", :controller=>"teeths"}
edit_teeth GET /teeth/:id/edit(.:format) {:action=>"edit", :singular=>"tooth", :controller=>"teeths"}
Also, I checked if there's a singular method, but that returns a NoMethodError. Is this something we would like to support with the new DSL?
Comments and changes to this ticket
-
Andrew White April 3rd, 2010 @ 07:21 AM
I saw it was missing the other day and thought about adding a patch, but I got the impression that the preferred method was to add a custom inflection.
I'll add a patch this evening and leave it up to core to decide what to do with it.
-
DHH April 3rd, 2010 @ 07:02 PM
I'm not sure I understand the value of this. It looks like all this does is change the name of the named route. What's the purpose here?
-
Rizwan Reza April 3rd, 2010 @ 07:05 PM
It fixes it when the singular-plural algorithm fails. It's your call. :)
-
DHH April 3rd, 2010 @ 07:06 PM
Ahh, okay. Well, you really should fix that in config/initializers/inflections.rb. Otherwise it's not going to be consistent in the rest of your app. I don't think we need it here unless there are other arguments for it.
-
Rizwan Reza April 3rd, 2010 @ 07:12 PM
- State changed from open to wontfix
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Medium
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>