Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Dynamic find_or_create_by_x_and_y always creates new records in Rails 2.3.11 #331
daphonz wants to merge 1 commit into rails:2-3-stablefrom daphonz:2-3-stable
Commits on Apr 28, 2011
Apr 28, 2011
…the find_by_* method. Closes issue #330. Commit fdfc8e3 introduced a bugfix to prevent additional values passed to a dynamic find_or_create_by_x methods from confusing the finder. This patch also broke the essential behavior of this method on an association by incorrectly sending arguments to the find_by_x methods. The finder method would always see its inputs as a single array of values instead of individual arguments, almost guaranteeing that the finder call would be incorrect, and that we'd always create a new record instead. This patch adds a splat operator to the parameter array we send along to the dynamic finder so that it receives its inputs correctly, and includes an additional test to ensure that repeated calls to find_or_create_by_x only creates one new record.