You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
The Defining Abilities wiki page states the following about using scopes:
You cannot use this with multiple can definitions that match the same action and model since it is not possible to combine them.
I would like to question this supposed impossibility.
Here is a quick proof of concept (read: hack) that can merge Hash and ActiveRecord::Relation conditions using arel 2.0.10 and cancan 1.6.7. It currently does not support negative abilities - which could be remedied by making the reduce phase a bit smarter - and always kicks in, even when no scopes are present.
All joins used in the scopes and hashes are also converted to outer joins since different joins may be necessary for different where conditions. This might have unintended side-effects and require an additional distinct/group by clause.