So I’ve been gradually getting my feet wet with the new Rails 2.0 release.
Then I ran into the changes to
A singular name is given to map.resource. The default controller name is still taken from the plural name.
This means that if you have the following in your
ActionController::Routing::Routes.draw do |map| map.resource :session end
Rails is going to look for a
SessionsController not a
even though you’re using the singular version, #resource, Rails is expecting a
plural controller name.
This is terrible. I just recently discovered the beauty of #resource and singleton controllers and now Rails 2.0 assumes that all singleton resources map to plural named controllers.
One of my favorite idioms was to use a singular resource for allowing users to edit their password (I always put password editing on a page separate from editing the rest of a user’s info, try keeping password changes along side your other user info changes and see how ugly your code gets. A separate controller cleans things up nice and allows you stay with CRUD naming for all your actions).
ActionController::Routing::Routes.draw do |map| map.resources :users do |user| user.resource :password end end
class UsersController < ApplicationController end class PasswordController < ApplicationController end
class UsersController < ApplicationController end class PasswordsController < ApplicationController end
I’ve refused to accept this new singular resource plural controller name style
and have resorted to specifying controller names in my
ActionController::Routing::Routes.draw do |map| map.resources :users do |user| user.resource :password, :controller => 'password' end end
Now I have to use this ugly hash of parameters to my
#resource call (also
Rails when are you going to let me use symbols for controller names? Strings
are hideous and break up the flow of my code).
I might have to patch Rails or at least say I will and not do anything.