I have User(has_one :profile) model linked to a Profile(belongs_to :user) model.
I will use username to slug profile url, the friendly shoud be implemented in User or Profile model?
Thank you!
I have User(has_one :profile) model linked to a Profile(belongs_to :user) model.
I will use username to slug profile url, the friendly shoud be implemented in User or Profile model?
Thank you!
I would still add it to Profile
, because you need it to build a profile_url
, not an user_url
, but then delegate username
to User
:
class Profile < ActiveRecord::Base
extend FriendlyId
belongs_to :user
friendly_id :username, use: :slugged
delegate :username, to: :user
# ...
end