开发者

Devise Accept Nested Attributes for Member problem

开发者 https://www.devze.com 2023-03-14 20:18 出处:网络
I am trying to have profile model in a devise Member model as a nested attribute. Here\'s my Member model:

I am trying to have profile model in a devise Member model as a nested attribute.

Here's my Member model:

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

I can ensure that the profile object for the Member has been created before saving the Member object. I enter all the necessary values, still I get this error at the output:

Email cannot be blank.

When I see in the terminal, all the fields have values, still I get this message.

And I see this warning in the terminal:

WARNING: Can't mass-assign protected attributes: em开发者_高级运维ail

Can anyone help?


Add :email to the attr_accessible call

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号