2013-12-16 77 views
0

我有以下類別:軌道4混合單複數資源

class User < ActiveRecord::Base 
    has_one :profile 
end 
class Profile < ActiveRecord::Base 
    belongs_to :user 
end 

我要揭露兩個URL的配置文件:

/profile # edit the profile of the logged in user 
/profiles/:id # view the profile of user :id 

好像我將不得不做對我的控制器進行相當程度的定製,並且對於應該相當普遍的情況發表看法。有沒有一個標準的方法來解決這個問題?

回答

0

您可能使這兩個途徑:

get '/profile', to: 'users#edit_current_user' 
get '/profiles/:id', to: 'users#show' 

每個動作應該做你的控制器方法想要什麼。