2012-03-12 76 views

回答

2

其实路线,我想你需要像这样在config/routes.rb

resources :users do 
    resources :profiles 
end 

以后,您可以通过发出命令检查您的REST-FUL资源路线:

rake routes 

这种方式,你有你的路线更自然的方式在您的用户将绑定到一个或多个配置文件,因此你可以使用类似:

user_profile_path(@user) 

创建一个相应链接到用户的个人资料。

3

config/routes.rb您需要添加1简单的线条:

resources :users 

,并得到所有这些东西

HTTP Verb Path   action named helper 

GET   /users   index  users_path 
GET   /users/new  new  new_user_path 
POST  /users   create users_path 
GET   /users/:id  show  user_path(:id) 
GET   /users/:id/edit edit  edit_user_path(:id) 
PUT   /users/:id  update user_path(:id) 
DELETE  /users/:id  destroy user_path(:id) 

你可以阅读有关轨道在the guides