title: Can't save nested_attributes use chosen in rails
body: <p>i try build a form using chosen and many to many relation, to store post > categories, i have some troubles</p>
  
  <p>1.- When i create a post i get this message <strong>Unpermitted parameter: categories</strong></p>
  
  <p>2.- Post is store but categories not saving</p>
  
  <p>Here is my code
  <strong>post.rb</strong></p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
      ...
  
      has_many :post_has_categories
      has_many :categories, through: :post_has_categories
  
      accepts_nested_attributes_for :post_has_categories,
                                    reject_if: :all_blank,
                                    allow_destroy: true
  
      serialize :category_ids, Array
      attr_accessor :categories
  
      # Virtual attributes
      def categories=(ids)
        self.category_ids = ids.split(",").map(&amp;:strip)
      end
  end
  </code></pre>
  
  <p><strong>post_has_category.rb</strong></p>
  
  <pre><code>class PostHasCategory &lt; ActiveRecord::Base
        belongs_to :post
        belongs_to :category
  
        accepts_nested_attributes_for :post
  end
  </code></pre>
  
  <p><strong>categories.rb</strong></p>
  
  <pre><code>class Category &lt; ActiveRecord::Base
      ...
  
      has_many :post_has_categories
      has_many :posts, through: :post_has_categories
  end
  </code></pre>
  
  <p>my partial <strong>posts#_form</strong> call data with this</p>
  
  <pre><code>&lt;%= f.select :categories, Category.all.map { |c| [c.name_category, c.id] },{}, { class: 'form-control', multiple: true } %&gt;
  </code></pre>
  
  <p>my <strong>posts_controller</strong> in strong_parameters i have this</p>
  
  <pre><code>params.require(:post).permit(..., post_has_categories_attributes: [ :post_id, :category_ids ])
  </code></pre>