This project is archived and is in readonly mode.
Resource controller name pluralization regression
Reported by Andrew White | June 26th, 2010 @ 08:24 AM | in 3.0.2
In Rails 2.3 the controller name is not forced to be a plural in a map.resources call, e.g:
map.resources :content
creates routes like this:
andyw$ rake routes
GET /content(.:format) {:action=>"index", :controller=>"content"}
contents POST /content(.:format) {:action=>"create", :controller=>"content"}
new_content GET /content/new(.:format) {:action=>"new", :controller=>"content"}
GET /content/:id(.:format) {:action=>"show", :controller=>"content"}
PUT /content/:id(.:format) {:action=>"update", :controller=>"content"}
content DELETE /content/:id(.:format) {:action=>"destroy", :controller=>"content"}
edit_content GET /content/:id/edit(.:format) {:action=>"edit", :controller=>"content"}
Whereas in 3.0:
resources :content
creates routes like this:
andyw$ rake routes
GET /content(.:format) {:controller=>"contents", :action=>"index"}
contents POST /content(.:format) {:controller=>"contents", :action=>"create"}
new_content GET /content/new(.:format) {:controller=>"contents", :action=>"new"}
GET /content/:id(.:format) {:controller=>"contents", :action=>"show"}
PUT /content/:id(.:format) {:controller=>"contents", :action=>"update"}
content DELETE /content/:id(.:format) {:controller=>"contents", :action=>"destroy"}
edit_content GET /content/:id/edit(.:format) {:controller=>"contents", :action=>"edit"}
The attached patch restores this behaviour.
Comments and changes to this ticket
-
Repository June 26th, 2010 @ 11:10 AM
- State changed from open to resolved
(from [9a6fc9a540cd23af3ca061cb7406a6cdd5ad4294]) Don't force pluralization of controller name when defining a resource [#4980 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/9a6fc9a540cd23af3ca061cb7406a6... -
Romain January 13th, 2011 @ 10:42 AM
Is it just me or is the very same bug still present in 3.0.3 on "map.resource" ?
For some reason,resource :admin, :only => [:show]
results in the following "rake routes" output :
admin GET /admin(.:format) {:controller=>"admins", :action=>"show"}
Notice how the "controller" name is pluralized (which IMHO makes even less sense since it's a singular resource).
-
David Phillips March 3rd, 2011 @ 10:33 PM
It seems intentional that singular resources pluralize the controller name. The routing guide has this note:
Because you might want to use the same controller for a singular route (/account) and a plural route (/accounts/45), singular resources map to plural controllers.
-
David Phillips March 3rd, 2011 @ 10:39 PM
I agree that pluralization by default rarely makes sense for singular resources, but unfortunately, it probably can't be changed now due to backwards compatibility.
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>
People watching this ticket
Attachments
Referenced by
- 4980 Resource controller name pluralization regression (from [9a6fc9a540cd23af3ca061cb7406a6cdd5ad4294]) Don't f...