2017-05-15 8 views
0

프로필 (belongs_to : user) 모델에 연결된 사용자 (has_one : 프로필) 모델이 있습니다.Friendly_id 사용자 또는 프로필 모델

나는 프로필 URL을 슬러그이하기 위해 사용자 이름을 사용할 것입니다. 친절한 의견은 사용자 또는 프로필 모델에 구현 되나요?

감사합니다.

+0

경우 사용자 또는 프로필의 이름 열은? – gates

답변

0

나는 당신이이 profile_url 아닌 user_url 구축해야하기 때문에 여전히 Profile에 추가,하지만 위임 할 usernameUser에 :

class Profile < ActiveRecord::Base 
    extend FriendlyId 

    belongs_to :user 

    friendly_id :username, use: :slugged 
    delegate :username, to: :user 

    # ... 
end