我正在尝试将设计模型中的配置文件模型作为嵌套属性。
这是我的会员模特:
class Member < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :username, :password, :password_confirmation, :remember_me, :profile_attributes
has_one :profile
has_many :bio_news_posts
accepts_nested_attributes_for :profile
end
我可以确保在保存Member对象之前已创建Member的profile对象。我输入了所有必要的值,但仍然在输出中出现此错误:
Email cannot be blank.
当我在终端中看到所有字段都有值时,我仍然收到此消息。
我在终端看到了这个警告:
WARNING: Can't mass-assign protected attributes: email
有人可以帮忙吗?
答案 0 :(得分:1)
将:email
添加到attr_accessible
来电