This project is archived and is in readonly mode.
find_or_create_by on an association always creates new records
-
Casey Dreier
Just to be clear, this bug report and patch are for Rails 2.3.11.
-
Jon Jensen
In addition to the incorrect behavior, it can also cause unhandled exceptions for postgres. For example, company.employees.find_or_create_by_group_id_and_name(1, 'bob') would generate some SQL like "... group_id IN (1, 'bob') AND name IS NULL". In postgres you get an error, since 'bob' hasn't been explicitly cast to an integer.
