-
-
Notifications
You must be signed in to change notification settings - Fork 356
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
Inconsistent behaviour between Symbol and Array scopes #155
Comments
Hi @ArnaudL, is this still an issue for you? I think this behaviour is consistent right back to the early days of Unfortunately we don't have time to work on new features like this at the moment. If you'd like to provide a PR with some tests then we'll definitely work with you on it, but otherwise I'm going to close this for now. :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
When a symbol is passed to an association, the scope column is inferred from the symbol:
=> will give a scope on "todo_list_id"
If the scope is an array, the name passed as an argument is used, without adding the _id suffix:
=> the scope is now "todo_list". The scope is then created with:
... but read_attribute on an association getter returns nil, which will give a query with
todo_list_id IS NULL
.I don't know what the best solution would be... An easy fix could be to use
send(column.intern)
instead ofread_attribute(column.intern)
.Another one would be to determine if the scope column is an association or not, with reflect_on_association, which could also be used to determine the foreign key instead of just appending _id to the name.
The text was updated successfully, but these errors were encountered: