Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Incorrect FK in nested models under Rails 3.2/PostgreSQL #22

@ealden

Description

@ealden

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

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions