이니까 localhost3000/users/edu/profile
을 달성하기 위해 FriendlyId를 사용하고 싶지만 어떻게해야할지 모르겠다! 나는FriendlyId가
class User < ActiveRecord::Base
has_one :user_profile, :dependent => :destroy
extend FriendlyId
friendly_id :name, :use => :slugged
end
class UserProfile < ActiveRecord::Base
attr_accessible :user_id, :name, :surname, :nickname
belongs_to :user
end
가 어떻게 사용자 USERPROFILE의 name
의 name
에 넣기 이러한 모델 사용자 및 사용자 프로필을? UserProfile의 이름이 변경되면 어떻게 사용자 이름을 업데이트합니까?
class User < ActiveRecord::Base
...
def name
if user_profile
"#{user_profile.name}"
end
end
을 사용하지만 내가 업데이트하거나 사용자 프로필에서 새 프로필을 만들 때 변경할 수 없습니다.
Ruby 1.9.3 및 Rails 3.2.13을 사용합니다.
감사합니다. 나는 그 이름을 위임했고 그것은 효과가 있었다. :) – edudepetris
니스, 잘 알고있다. :) – depa