Skip to content

Instantly share code, notes, and snippets.

@seban
Created February 9, 2016 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seban/4debf62a7568534b8562 to your computer and use it in GitHub Desktop.
Save seban/4debf62a7568534b8562 to your computer and use it in GitHub Desktop.
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