title: Factory Girl sets wrong value for auto-increment id in association
body: <p>I have two dependent models with one to many association</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    has_many :users
  end
  
  class User &lt; ActiveRecord::Base
    belongs_to :post
  end
  </code></pre>
  
  <p>in my DBMS <code>post_id</code> in <code>users</code> table is defined as a foreign key</p>
  
  <p>I wrote two cucumber scenarios - in first I(with factory_girl help) create two users and in second I also want to create two users but creation fails because <code>factory_girl</code> builds dependent <code>post</code> records with <code>id</code> set to one however in previous scenario two records in <code>posts</code> table were created and deleted so <code>id</code> value should start from <code>3</code> and not from <code>1</code>. I used <code>pry</code> to debug this process and spotted that if I use <code>FactoryGirl.build( :post )</code> it sets value properly but if I use <code>FactoryGirl.build( :user )</code> value of the associated <code>post.id</code> is always <code>1</code>. How can I make it buld records with proper <code>id</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>FactoryGirl.define do 
  
    sequence :composite_id do |n| 
      "F98F3806-#{sprintf("%04X", n)}-4C96-879C-2C6F38213D8E"
    end
  
    # Post 
    factory :post do
      sequence( :post_id ) { |n| "#{n}" }
      some_field "Lorem Ipsum is simply dummy text of the printing a"
      ...
    end
  
    # User
    factory :user do
      user_id { FactoryGirl.generate( :composite_id )}
      association :post_id, :factory =&gt; :post
      ...
    end
  
  end
  </code></pre>