title: having Can't mass-assign protected attributes: when there is attr_accessible
body: <p>In User.rb</p>
  
  <pre><code>  has_one :profile, :dependent =&gt; :destroy
    has_many :prints, :dependent =&gt; :destroy
    accepts_nested_attributes_for :profile
    before_create :build_profile
  
    # Setup accessible (or protected) attributes for your model
    attr_accessible :email, :password, :password_confirmation, :remember_me, :profile_attributes
  </code></pre>
  
  <p>Is there any problem with arrangements?</p>
  
  <p>Edit 1:</p>
  
  <p>Error is: "Can't mass-assign protected attributes: profile"</p>
  
  <p>Edit 2:</p>
  
  <p>my profile.rb model:</p>
  
  <pre><code>class Profile &lt; ActiveRecord::Base
    attr_accessible :name, :address, :phone
    belongs_to :user
  
  end
  </code></pre>
  
  <p>and my form:</p>
  
  <pre><code>&lt;%= form_for("user", :url =&gt; user_registration_path) do |f| %&gt;
    &lt;%= f.email_field :email, :autofocus =&gt; true, :placeholder =&gt; 'E-mail Address' %&gt;
    &lt;%= f.password_field :password, :placeholder =&gt; 'Password' %&gt;
    &lt;%= f.password_field :password_confirmation, :placeholder =&gt; 'Password Confirmation' %&gt;
  
    &lt;%= f.fields_for :profile do |profile_form| %&gt;
  
    &lt;%= profile_form.text_field :name, :placeholder =&gt; 'Name' %&gt;
    &lt;%= profile_form.text_field :address, :placeholder =&gt; 'Address' %&gt;
    &lt;%= profile_form.phone_field :phone, :placeholder =&gt; 'Phone (example: 0193284647)' %&gt;
  
   &lt;% end %&gt;
  
   &lt;p&gt;&lt;%= f.submit "Sign up", :class=&gt;'btn btn-primary' %&gt; &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Solution (using @Matt's answer):</p>
  
    
  
  <pre><code>&lt;%= profile_form.text_field :name, :placeholder =&gt; 'Name' %&gt;
  &lt;%= profile_form.text_field :address, :placeholder =&gt; 'Address' %&gt;
  &lt;%= profile_form.phone_field :phone, :placeholder =&gt; 'Phone (example: 0193284647)' 
  </code></pre>
  
    
  
  <p>so it will use the "accepts_nested_attributes_for :profile"</p>