Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_by modifies argument #284

Closed
astudnev opened this issue Oct 21, 2013 · 6 comments
Closed

find_by modifies argument #284

astudnev opened this issue Oct 21, 2013 · 6 comments

Comments

@astudnev
Copy link

argument to find_by is modified now by method

At least 2 tests now fail:

term = model.find_by(attrs) || model.create!(attrs)

term = model.find_by( non_modifiable_hash )

This may be related to #282

@shioyama
Copy link
Contributor

Can you write a test for this?

Yes globalize does modify the attributes, that's not a bug. But we hadn't considered non-modifiable hashes.

@shioyama
Copy link
Contributor

@shioyama
Copy link
Contributor

Actually this is a good catch, thanks. We just need to dup the hash before modifying it. If you have time a PR with the fix + a test would be great, otherwise I'll do it soon.

BTW this is not a problem only with find_by but with all methods overidden in relation.rb: where, etc.

@shioyama
Copy link
Contributor

Try the branch I just created:

gem 'globalize', github: 'globalize/globalize', branch: 'issue_284_find_by_arguments'

This should fix the modifying arguments issue.

@shioyama
Copy link
Contributor

This also seems to fix #283 , if so I'll just write a test for that and close both issues.

@astudnev
Copy link
Author

i tested with gem 'globalize', github: 'globalize/globalize', branch: 'issue_284_find_by_arguments'
and it works OK for #284 #283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants