title: has_one nested attributes not saving
body: <p>I have two models Project and ProjectPipeline.</p>
  
  <p>I want to create a Project form that also has fields from the ProjectPipeline model. I have created the form successfully but when I hit save the values aren't stored on the database. </p>
  
  <p><strong>project.rb</strong></p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
  
    has_one :project_pipeline
  
    accepts_nested_attributes_for :project_pipeline
  
    self.primary_key = :project_id
  end
  </code></pre>
  
  <p><strong>projectpipeline.rb</strong></p>
  
  <pre><code>class ProjectPipeline &lt; ActiveRecord::Base
  
    belongs_to :project, autosave: :true
  
    validates_uniqueness_of :project_id
  
  end
  </code></pre>
  
  <p>I don't always want a project pipeline but under the right conditions based on a user viewing a project. I want the project pipeline fields to be built, but only saved if the user chooses to save/populate them.</p>
  
  <p>So when the project is shown I build a temporary project pipeline using the project_id: from params[:id] (not sure if I really need to do this). Then when the project is saved I use the create_attributes. But if it has already been created or built I just want to let the has_one and belongs_to association kick in and then use update_attributes.</p>
  
  <p>My issue is when I am trying to save, I am either hitting a 'Forbidden Attribute' error if I use params[:project_pipeline] or having nothing saved at all if I used project_params. I have checked and rechecked all my fields are in project_params and even tried using a project_pipeline_params but that didn't feel right.</p>
  
  <p>It is driving me nuts and I need to sleep.</p>
  
  <p><strong>projects_controller.rb</strong></p>
  
  <pre><code>def show
    @project = Project.find(params[:id])
    if @project.project_pipeline
    else
      @project.build_project_pipeline(project_id: params[:id])
    end
    autopopulate
  end
  
  
  
  def update
      @project = Project.find(params[:id])
      if @project.project_pipeline
      else
        @project.build_project_pipeline(project_id: params[:id], project_type: params[:project_pipeline][:project_type], project_stage: params[:project_pipeline][:project_stage])
      end
      if @project.update_attributes(project_params)
        flash[:success] = "Project Updated"
        redirect_to [@project]
      else
        render 'edit'
      end
    end
  
  
  def project_params
    params.require(:project).permit(:user_id, project_pipeline_attributes:[:project_id,:project_type,:project_stage,
        :product_volume,:product_value,:project_status,:outcome, :_destroy])
  end
  </code></pre>
  
  <p><strong>show.html.haml</strong></p>
  
  <pre><code>    - provide(:title, "Show Project")
  %h1= @project.project_title
  = simple_form_for(@project) do |f|
    = f.input  :id, :as =&gt; :hidden, :value =&gt; @project, :readonly =&gt; true  
    = f.input :user_id, label: 'Assigned to Account Manager', :collection =&gt; @account_managers, :label_method =&gt; lambda { |r| "#{r.first_name} #{r.last_name}" }
    = f.input :project_id, :readonly =&gt; true
    = f.input :status, :readonly =&gt; true
    = f.input :project_stage, :readonly =&gt; true
  
    - if @project.project_codename = "project pipeline"
      = simple_fields_for @project.project_pipeline do |i|
        %h2 Project Pipeline
        - if @project.user_id == current_user.id
          = i.input :project_volume, label: 'Project Status', collection: @project_status
          = i.input :project_value, label: 'Project Status', collection: @project_status
          = i.input :project_status, label: 'Project Status', collection: @project_status
        = i.input :outcome, label: 'Outcome', collection: @outcome
  
  
      = f.submit 'Save'
  </code></pre>
  
  <p>If you've gotten this far I sincerely thank you.</p>