Skip to content

Instantly share code, notes, and snippets.

@Austio
Last active August 29, 2015 14:05
Show Gist options
  • Save Austio/1bac0bf50445d2b3806e to your computer and use it in GitHub Desktop.
Save Austio/1bac0bf50445d2b3806e to your computer and use it in GitHub Desktop.
app/policies/court_policy.rb
```
class CourtPolicy < ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
user.has_role? :admin
end
end
```
app/policies/application_policy.rb
```
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
false
end
end
```
app/controllers/application_controller.rb
```
class ApplicationController < ActionController::Base
include Pundit
end
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment