。以下是我的用戶和配置文件模型,任何解決方案?協會工作不
Profile.rb
class Profile < ActiveRecord::Base
belongs_to :user
end
user.rb
class User < ActiveRecord::Base
has_one :profile
#callback that creates a profile for each user that signs up
after_create :create_profile
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
private
def create_profile
self.profile = Profile.create
end
end
這個文檔讀取比後者好得多。謝謝 – samsos