Created
February 9, 2016 07:53
-
-
Save seban/4debf62a7568534b8562 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TravelDocumentPolicy | |
def create? | |
user.agent? || user.superagent? | |
end | |
def update? | |
create? | |
end | |
end | |
#### Or | |
class ApplicationPolicy | |
private | |
def self.permit_ah_agents_to(*actions) | |
actions.each do |action| | |
define_method("#{ action }?") do | |
user.agent? || user.superagent? | |
end | |
end | |
end | |
end | |
class TravelDocumentPolicy | |
permit_ah_agents_to :create, :update | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment