title: FactoryGirl: why does attributes_for omit some attributes?
body: <p>I want to use FactoryGirl.attributes_for in controller testing, as in:</p>
  
  <pre><code>it "raise error creating a new PremiseGroup for this user" do
    expect {
      post :create, {:premise_group =&gt; FactoryGirl.attributes_for(:premise_group)}
    }.to raise_error(CanCan::AccessDenied)
  end
  </code></pre>
  
  <p>... but this doesn't work because #attributes_for omits the :user_id attribute.  Here is the difference between <code>#create</code> and <code>#attributes_for</code>:</p>
  
  <pre><code>&gt;&gt; FactoryGirl.create(:premise_group)
  =&gt; #&lt;PremiseGroup id: 3, name: "PremiseGroup_4", user_id: 6, is_visible: false, is_open: false)
  &gt;&gt; FactoryGirl.attributes_for(:premise_group)
  =&gt; {:name=&gt;"PremiseGroup_5", :is_visible=&gt;false, :is_open=&gt;false}
  </code></pre>
  
  <p>Note that the :user_id is absent from <code>#attributes_for</code>.  Is this the expected behavior?</p>
  
  <p>FWIW, my factories file includes definitions for <code>:premise_group</code> and for <code>:user</code>:</p>
  
  <pre><code>FactoryGirl.define do
    ...
    factory :premise_group do
      sequence(:name) {|n| "PremiseGroup_#{n}"}
      user
      is_visible false
      is_open false
    end
    factory :user do
      ...
    end
  end
  </code></pre>