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

ObligationScope should use references in Rails 4 when it uses includes. #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aepstein
Copy link
Contributor

Before Rails 4, includes would also outer join tables if query conditions referenced those tables. Rails 4 has dropped this behavior in favor of making the developer explicitly identify includes that must also be joined with an additional references() method on the scope. @zeiv modified tests to use references(), but it seems better to me to incorporate this directly into the scope() method of ObligationScope. This PR reverts the Rails 4-specific tests and instead sets references in Rails >= 4.

@besief
Copy link

besief commented Jan 16, 2015

This is great and useful!

@dgm
Copy link

dgm commented Feb 25, 2016

+1 Trying to upgrade from rails 3 and running into this all over the place

@dgm
Copy link

dgm commented Feb 25, 2016

To elaborate further - The tables to include in the references depends completely upon the rules set. One role may need to reference one table, and another role may need to reference another. The knowledge of this should be handled within declarative_authorization, not in the calling code...

dgm added a commit to wested/declarative_authorization that referenced this pull request Feb 25, 2016
Use references with includes to make sure the query doesn't fail
@annaswims
Copy link

I believe this will fix my rails 4.1 problems. Thanks @aepstein

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

Successfully merging this pull request may close these issues.

4 participants