title: Rails 4: Create new records through has_many association
body: <p>I am trying to create a new record for 'campaign' via the 'customer' as follows. The form submits correctly, however no new campaign record is created for the customer. Any advise would be greatly appreciated.</p>
  
  <p><strong>Models</strong></p>
  
  <pre><code>class Customer::Customer &lt; User
    has_one :library, dependent: :destroy
    has_many :campaigns, dependent: :destroy
    accepts_nested_attributes_for :campaigns, :library,  allow_destroy: true
  end
  
  class Customer::Campaign &lt; ActiveRecord::Base
    belongs_to :customer
  end
  </code></pre>
  
  <p>Customer Controller - Update Method only shown</p>
  
  <pre><code>class Customer::CustomersController &lt; ApplicationController
    layout "customer_layout"
    def update
      session[:return_to] ||= request.referer
      @customer = User.find(params[:id])
      if @customer.update_attributes(customer_params)
        flash[:success] = "Profile updated"
        redirect_to @customer
      else
        flash[:notice] = "Invalid"
        redirect_to session.delete(:return_to)
      end
    end
  
    def customer_params
      params.require('customer_customer').permit(:name, :email, :password, :password_confirmation, :country_code, :state_code, :postcode, :first_name, :surname, campaigns_attributes:[:name, :description, :start_date, :complete_date ])
    end
  end
  </code></pre>
  
  <p>And the form I am using</p>
  
  <pre><code>&lt;%= form_for @customer do |f| %&gt;
    &lt;%= render 'shared/customer_error_messages' %&gt;
    &lt;%= f.fields_for :campaign do |builder| %&gt;
      &lt;%= builder.label :name, "Campaign Name" %&gt;&lt;/br&gt;
      &lt;%= builder.text_field :name %&gt;
    &lt;% end %&gt;
    &lt;div class="actions"&gt;
      &lt;%= f.submit class: "btn btn-large btn-primary"%&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>And the console output (with error, is as follows)</p>
  
  <pre><code>Started PATCH "/customer/customers/38" for 127.0.0.1 at 2014-05-26 23:13:10 +1000
  Processing by Customer::CustomersController#update as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"9ChLYna0/VfZSMJOa2yGgvWTT61XkjoYwlVup/Pbbeg=", "customer_customer"=&gt;{"campaign"=&gt;{"name"=&gt;"My new campaign"}}, "commit"=&gt;"Update Customer", "id"=&gt;"38"}
    User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."remember_token" = '0e8b4ba6dc957e76948fc22bae57673404deb9fe' LIMIT 1
    User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", "38"]]
    CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", "38"]]
  Unpermitted parameters: campaign
  </code></pre>