Handle Ruby on Rails resource when the singular is also plural?
Whats the best way to handle a singular resource, that itself is plural.
For example a "settings page", that displays a selection of different settings. As I am displaying a single "Settings" instance, I would expect to use the show action, but would want to have "settings" not "setting" in the url.
If I called the resource "settings_group" it would solve the problem, but that name is far from catchy, and not an ideal soluti开发者_开发知识库on.
Thanks
A quick way to achieve this is to write it yourself:
resources :settings, :except => :show
match "settings/:id" => "settings#show", :as => :setting
In Rails 2.x, you can do
resource :setting, :as => 'settings'
The generated URLs will use setting
, though.
精彩评论