title: Rails 3.1 -- Can't mass assign protected attributes (even though added to attr_accessible)
body: <p>I have a nested form <code>categories</code> for <code>stores</code> and have it listed as attr_accessible in the store model. But still keep getting the following error:</p>
  
  <pre><code>WARNING: Can't mass-assign protected attributes: category_ids
  </code></pre>
  
  <p>I've tried all variations of attr_accessible in the store model:</p>
  
  <pre><code>attr_accessible :categories
  attr_accessible :category
  attr_accessible :category_id
  attr_accessible :category_ids
  </code></pre>
  
  <p>None of them work! Both these models are has_and_belongs_to_many (and have a joining table called categories_stores).</p>
  
  <p>Any advice would be greatly appreciated (I've been banging my head against the wall for two days over this).</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've implemented a <strong>temporary fix</strong> (which is pretty redundant and not needed if rails just adhered to the above problem). I fixed it by overwriting the <code>create</code> method for ActiveAdmin and looping to insert the association data:</p>
  
  <pre><code>  controller do
      def update
        @store = store.find(params[:id])
        if @store.update_attributes(params[:store])
          @store.categories.delete_all
          params[:store][:category_ids].each do |category_id|
            @store.categories &lt;&lt; Category.find(category_id) unless category_id.blank?
          end
          redirect_to :action =&gt; :index
        else
          redirect_to :action =&gt; :edit, :notice =&gt; "Something f'ed up"
        end
      end
  
    end
  </code></pre>