Merge pull request #717 from drewmoore/update-documentation-for-headless-policies
Remove Struct inheritance from headless policy example
This commit is contained in:
commit
54675c6f9b
13
README.md
13
README.md
|
@ -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
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue