title: Inexplicable unpermitted parameters error in Rails 4 nested form
body: <p>I've searched high and low, and found many posts similiar, but can't seem to debug the following code.</p>
  
  <p>I have a project model, which has many many teams. It has many users through teams. Here are the relevant models.</p>
  
  <p><strong>project.rb</strong></p>
  
  <pre><code> class Project &lt; ActiveRecord::Base
     has_many :teams
     has_many :users, :through =&gt;  :teams
  
     accepts_nested_attributes_for :teams
   end
  </code></pre>
  
  <p><strong>team.rb</strong></p>
  
  <pre><code>class Team &lt; ActiveRecord::Base
    belongs_to :project
    belongs_to :user
  end
  </code></pre>
  
  <p><strong>user.rb</strong></p>
  
  <pre><code> class User &lt; ActiveRecord::Base
     has_many :teams
     has_many :projects, :through =&gt; :teams
   end
  </code></pre>
  
  <p><strong>projects_controller.rb</strong></p>
  
  <pre><code>class ProjectsController &lt; ApplicationController
    def index
      @projects = Project.all
    end
  
    def new
      @project = Project.new
    end
  
    def create
      @project = Project.create(project_params)
      redirect_to projects_url
    end
  
    def show
      @project = Project.find(params[:id])
    end
  
    def edit
      @project = Project.find(params[:id])
    end
  
    def update
      @project = Project.find(params[:id])
      @project.update(type_params)
      redirect_to project_url
    end
  
    def destroy
      @project = Project.find(params[:id])
      @project.destroy
      redirect_to projects_url
    end
  
  end
  
  private
  
  def project_params
    params.require(:project)
    project_params = params.require(:project).
    permit(:name, :code, :description, :externalId,
         {:teams_attributes =&gt; [:id, :userId, :projectId]})
  end
  </code></pre>
  
  <p>I have a nested form, that should allow me to create a new project and one team (just typing in the ID), however I get an unpermitted parameters exception ("Unpermitted parameters: team")</p>
  
  <p>Whenever I submit the form. Form code is below.</p>
  
  <p><strong>new.html.erb</strong></p>
  
  <pre><code>&lt;h1&gt;Create New Project&lt;/h1&gt;
  
  &lt;%=form_for(@project) do |f| %&gt;
  
  &lt;p&gt;
    &lt;%=f.label "Name"%&gt;
    &lt;%=f.text_field :name%&gt; &lt;br&gt;
  
    &lt;%=f.label "Code"%&gt;
    &lt;%=f.text_field :code%&gt; &lt;br&gt;
  
    &lt;%=f.label "External ID"%&gt;
    &lt;%=f.text_field :externalId%&gt; &lt;br&gt;
  
    &lt;%=f.label "Description"%&gt;
    &lt;%=f.text_field :description%&gt; &lt;br&gt;
  &lt;/p&gt;
  
  &lt;ul&gt;
    &lt;%= f.fields_for :team do |tf| %&gt;
        &lt;li&gt;
          &lt;%= tf.label 'User Id' %&gt;
          &lt;%= tf.text_field :userId %&gt;
          &lt;%= tf.label 'Project Id' %&gt;
          &lt;%= tf.text_field :projectId %&gt;
        &lt;/li&gt;
  &lt;/ul&gt;
    &lt;%end%&gt;
   &lt;%=f.submit%&gt;
  
   &lt;%end%&gt;
  </code></pre>
  
  <p>I've paid special attention to the permitted parameters fields, and think I got them right, but, rails disagrees.</p>
  
  <p>Any help would be appreciated</p>