Merge pull request #717 from drewmoore/update-documentation-for-headless-policies

Remove Struct inheritance from headless policy example
This commit is contained in:
Kim Burgestrand 2022-02-11 10:26:12 +01:00 committed by GitHub
commit 54675c6f9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -196,8 +196,17 @@ you can retrieve it by passing a symbol.
```ruby
# app/policies/dashboard_policy.rb
class DashboardPolicy < Struct.new(:user, :dashboard)
# ...
class DashboardPolicy
attr_reader :user
# _record in this example will just be :dashboard
def initialize(user, _record)
@user = user
end
def show?
user.admin?
end
end
```