title: Rails Collection Select in Form Not Saving HABTM Association
body: <p>In my Rails form, the associations aren't saving when I put a multiple collection select option in the form. Why is this?</p>
  
  <p><strong>Form</strong></p>
  
  <pre><code>&lt;%= form_for @entry do |f| %&gt;
    &lt;% if @entry.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@entry.errors.count, "error") %&gt; prohibited this entry from being saved:&lt;/h2&gt;
  
        &lt;ul&gt;
        &lt;% @entry.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label :content %&gt;&lt;br&gt;
      &lt;%= f.text_area :content %&gt;
    &lt;/div&gt;
  
    &lt;div class="field"&gt;
      &lt;%= f.label :category_ids, "Categories" %&gt;&lt;br /&gt;
      &lt;%= f.collection_select :category_ids, Category.order(:name), :id, :name, {}, {multiple: true} %&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= f.submit 'Submit' %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>Strong Parameters</strong></p>
  
  <pre><code>private
      def entry_params
          params.require(:entry).permit(:content, :category_ids)
      end
  </code></pre>
  
  <p><strong>Entry Model</strong></p>
  
  <pre><code>class Entry &lt; ActiveRecord::Base
    belongs_to :user
    has_and_belongs_to_many :categories
  
    validates :content, :user_id, presence: true
  end
  </code></pre>
  
  <p><strong>Category Model</strong></p>
  
  <pre><code>class Category &lt; ActiveRecord::Base
    belongs_to :user
    has_and_belongs_to_many :entries
  end
  </code></pre>
  
  <p><strong>Join Table</strong></p>
  
  <pre><code>class EntriesCategories &lt; ActiveRecord::Base
      belongs_to :entry
      belongs_to :categories
  end
  </code></pre>