---
title: rails 2 point oh jesus
teaser:
tags: web,rails
author: Jared Carroll
published_on: 2008-01-08
---

So I’ve been gradually getting my feet wet with the new Rails 2.0 release.

Then I ran into the changes to `ActionController::Resources#resource`:

> 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 `routes.rb`.

    ActionController::Routing::Routes.draw do |map|

      map.resource :session

    end

Rails is going to look for a `SessionsController` not a `SessionController`.  So
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 <abbr title="Create Read Update
Delete">CRUD</abbr> naming for all your actions).

```ruby
ActionController::Routing::Routes.draw do |map|

  map.resources :users do |user|
    user.resource :password
  end

end
```

Goes from

```ruby
class UsersController < ApplicationController
end

class PasswordController < ApplicationController
end
```

to

```ruby
class UsersController < ApplicationController
end

class PasswordsController < ApplicationController
end
```

What trash.

I’ve refused to accept this new singular resource plural controller name style
and have resorted to specifying controller names in my `routes.rb` file.

```ruby
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.
