title: Why is this rails nested attributes assignment not working
body: <p>I've a Rails model called Biography, and biography has one lifestyle.</p>
  
  <pre><code>class Lifestyle &lt; ActiveRecord::Base
      belongs_to :biography
  end
  
  class Biography &lt; ActiveRecord::Base
    has_one :lifestyle, dependent: :destroy
    accepts_nested_attributes_for :lifestyle
  end
  </code></pre>
  
  <p>And In my BiographyController I've this:</p>
  
  <pre><code>def update_biography
    biography = current_user.biography
    logger.debug("params are: #{params}")
    logger.debug("biography_params are: #{biography_params}")
    if biography.update(biography_params)
      render :json =&gt; biography
    else
      render :json =&gt; { :errors =&gt; biography.errors.full_messages }, :status =&gt; 400
    end
  end
  
  def biography_params
              params.require(:biography).permit(
                                        :disability, :hiv_positive, :blood_type,
                                        lifestyle_attributes: [:id, :diet, :smoke, :drink])
  end
  </code></pre>
  
  <p>And this is what I get from my two logger.debug statements above:</p>
  
  <pre><code>params are: {"lifestyle_attributes"=&gt;{"diet"=&gt;"2", "smoke"=&gt;"false", "drink"=&gt;"2"}, "disability"=&gt;"false", "hiv_positive"=&gt;"false", "blood_type"=&gt;"3", "controller"=&gt;"biographies", "action"=&gt;"update_biography", "id"=&gt;"4", "biography"=&gt;{"disability"=&gt;"false", "hiv_positive"=&gt;"false", "blood_type"=&gt;"3"}}
  
  biography_params are: {"disability"=&gt;"false", "hiv_positive"=&gt;"false", "blood_type"=&gt;"3"}
  </code></pre>
  
  <p>Why is that my biography_params do not contain lifestyle_attributes even though I've accepts_nested_attributes_for statment in the Biography model, and also defining association between Biography and Lifestyle in the models?  I've also added lifestyle_attributes in the strong parameters permit list.</p>
  
  <p>However, if I run this in rails console the assignment does work:</p>
  
  <pre><code>b = Biography.first
  b.update("lifestyle_attributes"=&gt;{"diet"=&gt;"2", "smoke"=&gt;"false", "drink"=&gt;"2"})
  </code></pre>