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

Finders with hash attributes are not supported #36

Closed
baldursson opened this issue Jul 15, 2013 · 3 comments
Closed

Finders with hash attributes are not supported #36

baldursson opened this issue Jul 15, 2013 · 3 comments

Comments

@baldursson
Copy link

This works:
SubModel.where("attribute = ?", value)

This does not:
SubModel.where(attribute: value)

And I guess that is also related to why this is not supported:
SubModel.find_or_create_by(attribute: value)

It's not crucial, since there are workarounds, but it forces me to write my code in a way I wouldn't normally do. Hashes are simply more elegant.

@hzamani
Copy link
Owner

hzamani commented Jul 15, 2013

When useign hash conditions you have to use association key to specify the model, something like this:

SubModel.find_or_create_by(supermode: {attribute: value})

And thats why find_or_create_by don't work as well.

We may fix this (or at fix least find_or_create_by) but as we go along things are getting more and more messy!
Are there any idea on how to get raid of this simulation, and have real multi-table-inheritance?

@mfoste
Copy link

mfoste commented Apr 10, 2014

Going from Rails 4.0 to 4.1, I had to change from using the superclass singular association key name to using the plural superclass table name:

SubModel.where(supermodel: {attribute: value})

Changed to

SubModel.where(supermodels: {attribute: value})

activefx added a commit to activefx/acts_as_relation that referenced this issue Apr 13, 2014
@hzamani
Copy link
Owner

hzamani commented Jul 29, 2014

fixed in active_record-acts_as gem

@hzamani hzamani closed this as completed Jul 29, 2014
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

3 participants