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
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
精彩评论