ryanb/populator — Issue #22: Incorrect FK in nested models under Rails 3.2/PostgreSQL
Author: ealden
Created: 2012-01-30 16:56:08+00:00
State: open

I am currently on Rails 3.2 with PostgreSQL as database, and the following example does not work as expected:

```ruby
Foo.populate 10 do |foo|
Bar.populate 10 do |bar|
bar.foo_id = foo.id
end
end
```

The entries for Bar should be linked to Foo through a foreign key. Instead the value of foo.id inside Bar seems to start from 0 always, thus, running a `rake db:populate` multiple times would cause the id of Foo to move forward (as it does not reset by default) and lead to Bar linking to the incorrect Foo.

This commit from route/populator@5c1da8c3784e6322c3d26f3b1c4511daeecb7a80 seems to fix this - might be a good idea to merge?