Class | CanCan::ModelAdapters::ActiveRecordAdapter |
In: |
lib/cancan/model_adapters/active_record_adapter.rb
|
Parent: | AbstractAdapter |
Returns conditions intended to be used inside a database query. Normally you will not call this method directly, but instead go through ModelAdditions#accessible_by.
If there is only one "can" definition, a hash of conditions will be returned matching the one defined.
can :manage, User, :id => 1 query(:manage, User).conditions # => { :id => 1 }
If there are multiple "can" definitions, a SQL string will be returned to handle complex cases.
can :manage, User, :id => 1 can :manage, User, :manager_id => 1 cannot :manage, User, :self_managed => true query(:manage, User).conditions # => "not (self_managed = 't') AND ((manager_id = 1) OR (id = 1))"
Returns the associations used in conditions for the :joins option of a search. See ModelAdditions#accessible_by