This project is archived and is in readonly mode.
Rails 3 forces singleton resource names to be a singular word
Reported by Mislav | March 2nd, 2010 @ 07:10 AM | in 3.0.2
I want a resource named "preferences" in Rails 3, but current routing implementation forces singleton resource names to singular form regardless of if they were specified in plural. In this example:
resource :preferences
generates these helpers: admin_preference, new_admin_preference, edit_admin_preference (notice the singular form)
Accordingly, the URLs for this resource are in the "/preference/*" form.
For now, I'm using this workaround to fix the URLs:
resource :preferences, :as => :preferences
But the generated URL helpers stay in singular form.
In Rails 2.3.x it was possible to have a singleton route named with a plural word.
Comments and changes to this ticket
-
José Valim March 3rd, 2010 @ 08:39 AM
- Assigned user set to josh
- Milestone cleared.
-
josh March 6th, 2010 @ 07:08 PM
- State changed from new to wontfix
Hmm, I'm split here.
Enforcing the singular convention and requiring explicit overrides seems good in a way.
resource :preference, :as => :preferences
If you really want this, I'll accept a patch for it.
-
Mislav March 10th, 2010 @ 03:27 AM
I'm all for explicit overrides, but
:as
only lets me manually override the path segment. The url helpers still remain in singular form, and I want them in plural because that's how they were in the 2.3.x app.To me,
preference_path
just looks wrong. It's not a single preference. It's a page with multiple preferences. Still, there's no way of overriding what word form will be used for these helpers. -
Andrew White March 10th, 2010 @ 12:29 PM
- Tag changed from pluralize, rails3, resource, routing, singleton to patch, pluralize, rails3, resource, routing, singleton
This is also a problem for me bringing sites forward as most of them have singleton resources named settings. Obviously it's a relatively easy fix to search and replace settings_path with setting_path in all the views but I'm in agreement with Mislav that it just looks wrong.
I've attached a patch which restores the behaviour from 2.3 and adds a failing test.
BTW, I had to update rack-mount to 0.6.1 to get all the tests to pass - maybe you want to bump the dependency in the gemspec.
-
josh March 10th, 2010 @ 02:10 PM
- State changed from wontfix to open
-
Repository March 15th, 2010 @ 02:46 PM
- State changed from open to resolved
(from [96bc6bcfee704701de1a9c4c3c6a7c265610d34d]) Don't force singularization of singleton resource names, e.g. /preferences [#4089 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com
http://github.com/rails/rails/commit/96bc6bcfee704701de1a9c4c3c6a7c... -
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
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
- 4089 Rails 3 forces singleton resource names to be a singular word (from [96bc6bcfee704701de1a9c4c3c6a7c265610d34d]) Don't f...