Commit fd44e195 authored by Kirstie Cook's avatar Kirstie Cook

Refer to Ability.allowed? instead of Ability.can?

parent a1db3934
......@@ -123,7 +123,7 @@ class FooPolicy < BasePolicy
end
```
Naively, if we call `Ability.can?(user1, :some_ability, foo)` and `Ability.can?(user2, :some_ability, foo)`, we would have to calculate the condition twice - since they are for different users. But if we use the `scope: :subject` option:
Naively, if we call `Ability.allowed?(user1, :some_ability, foo)` and `Ability.allowed?(user2, :some_ability, foo)`, we would have to calculate the condition twice - since they are for different users. But if we use the `scope: :subject` option:
```ruby
condition(:expensive_condition, scope: :subject) { @subject.expensive_query? }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment