title: ActiveRecord::AssociationTypeMismatch in Controller (rails)
body: <p>I try to submit a form for a proposal.  The form consists of choosing a model from a collection of countries and entering in a few text boxes.  However, when I go to select the country, Rails says it is getting a string when it expects a country.</p>
  
  <p>Proposal model: </p>
  
  <pre><code>class Proposal &lt; ActiveRecord::Base
      belongs_to :my_user, class_name: "User", foreign_key: "user_id"
      belongs_to :country, class_name: "Country", foreign_key: "country_id"
      after_initialize :set_defaults
  
      validates :status, presence: true
      validates :country, presence: true
      validates :q1, length: {maximum: 250}
      validates :q2, length: {maximum: 250}
      .
      .
      .
      validates :q30, length: {maximum: 250}
  
      def set_defaults
          self.status = "Pending"
      end
  end
  </code></pre>
  
  <p>Proposal controller:</p>
  
  <pre><code>class ProposalsController &lt; ApplicationController
    before_action :authenticate_user!, only: [:new, :create]
  
    def index
      @proposals = Proposal.all
    end
  
    def new
      @proposal = Proposal.new
    end
  
    def create
      @proposal = Proposal.new(params.require(:proposal).permit(:status, :country,  
      :q1, 
      :q2,
      .
      .
      .
      :q30))
      @proposal.save!
      redirect_to home_path
    end
  
    def display
      @proposal = Proposal.find(params[:id])
    end
  end
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;div class="container-fluid text-center"&gt;
    &lt;div class="row content"&gt;
      &lt;div class="col-sm-12 text-left"&gt;
  
         &lt;%= form_for(@proposal) do |f| %&gt;
            &lt;%= f.collection_select(:country, Country.all.order('name'), :id, :name) %&gt;
            &lt;br&gt;&lt;p&gt;&lt;%= f.submit %&gt;&lt;/p&gt;&lt;br&gt;
         &lt;% end %&gt;
  
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Migration:</p>
  
  <pre><code>class CreateProposals &lt; ActiveRecord::Migration
    def change
      create_table :proposals do |t|
        t.string :status, :default =&gt; "Pending"
        t.integer :country_id
        t.text :q1 
        t.text :q2 
        .
        .
        .
        t.text :q30
  
        t.timestamps null: false
      end
    end
  end
  </code></pre>