title: Where to permit a parameter in a has_one/belongs_to association?
body: <p>When I try and edit the Contact to add a DataType, I receive a: 'Unpermitted parameter: data_format' error. I have tried following similar associations I have found online, but can't figure out what I am missing. I apologize if this is redundant. </p>
  
  <p>Here are the relevant pieces of information:</p>
  
  <p><strong>Models:</strong></p>
  
  <pre><code># == Schema Information
  #
  # Table name: contacts
  #
  #  id          :integer          not null, primary key
  #  name        :string
  #  email       :string
  #  phone       :string
  #  mobile      :string
  #  created_at  :datetime         not null
  #  updated_at  :datetime         not null
  #  supplier_id :integer
  #
  class Contact &lt; ActiveRecord::Base
      has_one :data_type
      accepts_nested_attributes_for :data_type, allow_destroy: true
  end
  # == Schema Information
  #
  # Table name: data_formats
  #
  #  id         :integer          not null, primary key
  #  name       :string
  #  created_at :datetime         not null
  #  updated_at :datetime         not null
  #  contact_id :integer
  #
  class DataFormat &lt; ActiveRecord::Base
      belongs_to :contact
  end
  </code></pre>
  
  <p><strong>Contact Controller:</strong></p>
  
  <pre><code>class ContactsController &lt; ApplicationController
    before_action :set_contact, only: [:show, :edit, :update, :destroy]
  
    def new
      @contact = Contact.new
    end
  
    def create
      @contact = Contact.new(contact_params)
  
      respond_to do |format|
        if @contact.save
          format.html { redirect_to @contact, notice: 'Contact was successfully created.' }
          format.json { render :show, status: :created, location: @contact }
        else
          format.html { render :new }
          format.json { render json: @contact.errors, status: :unprocessable_entity }
        end
      end
    end
  
    private
  
      def set_contact
        @contact = Contact.find(params[:id])
      end
  
      def contact_params
        params.require(:contact).permit(:name, :email, :phone, :mobile, :data_format,
                                        data_format_attributes: [ :id, :name, :contact_id, :_destroy ] )
      end
  end
  </code></pre>
  
  <p><strong>Edit View:</strong></p>
  
  <pre><code>&lt;%= simple_form_for @contact do |f| %&gt;
    &lt;div class="form-group"&gt;
      &lt;div class="col-lg-6"&gt;
        &lt;%= f.input :name %&gt;
      &lt;/div&gt;
      &lt;div class="col-lg-6"&gt;
        &lt;%= f.simple_fields_for :data_format do |t| %&gt;
          &lt;%= t.input :id, label: 'Date Format:', :collection =&gt; DataFormat.order(:name) %&gt;
        &lt;% end %&gt;
      &lt;/div&gt;
      &lt;div class="col-lg-6"&gt;
        &lt;%= f.label "Submit", class: 'control-label' %&gt;
        &lt;%= f.button :submit, class: 'btn btn-primary form-control' %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>The DataType(s) are appearing in the form and I can select them. So, I know the issue must be within the controller. </p>
  
  <p>Any help would be greatly appreciated!</p>