1 map.resources :users 2 map.resource :session
routes.rbに出てくる、map.resour
map.resour
Creates named routes for implementi
ng verb-orien ted controller s for a singleton resource. A singleton resource is global to the current user visiting the applicatio n, such as a user‘s /account profile.
単数コントローラ名でパスを提供する場合に使えるようです。
- a singular name is given to map.resour
ce. The default controller name is taken from the singular name. - To specify a custom plural name, use the :plural option. There is no :singular option
- No default index, new, or create routes are created for the singleton resource controller
. - When nesting singleton resources, only the singular name is used as the path prefix (example: 'account/me
ssages/1')
- 単数形を使ったリソースを提供できます
- :pluralオプションを使えば、複数を使うこともOK。:singularオプションはありません。
- index, new, createのroutesは作られません
- 入れ子で単数形resourceを使っている場合、prefixには単数形が使われます
ex 'account/messages/1'
ヘルプにある生成されるというパスと私の環境のrake routesで表示されるパスが異なるようなので使用しているrailsで確認することが必要があるように思います。
posted by
satoko
on Wed 28 Nov 2007
at 05:51