fl00r
fl00r

Reputation: 83680

Why should I pluralize controller name for RESOURCE

I understand that there is a convention, about controllers' names so it should be pluralised.

But why should I pluralize controller's name for resource?

So this is ok:

resources :apples

But this is not:

resource :apple, :controller => "apple"

Why just not?

resource :apple 

Upvotes: 1

Views: 351

Answers (1)

Mario
Mario

Reputation: 2942

resource is different from resources. It's used if you have just one.

As this guide explains, it's useful if you only ever reference one. If you have, for example, a profile that you never mention the id, you just assume the current user needs to access or edit their own profile.

You can mix these, too. So say you want users to be able to view each other's profiles, but also have a url for their own profile:

resources :profiles
resource :profile

Upvotes: 3

Related Questions