stffn / declarative_authorization

An unmaintained authorization plugin for Rails. Please fork to support current versions of Rails
MIT License
1.24k stars 233 forks source link

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

Open aepstein opened 10 years ago

aepstein commented 10 years ago

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 commented 9 years ago

This is great and useful!

dgm commented 8 years ago

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

dgm commented 8 years ago

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...

annaswims commented 8 years ago

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