Skip to content

Instantly share code, notes, and snippets.

@knoxknox
Created November 18, 2014 21:28
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 knoxknox/bc812a577af137974464 to your computer and use it in GitHub Desktop.
Save knoxknox/bc812a577af137974464 to your computer and use it in GitHub Desktop.
# syntax
can(action, object_class)
# ability.rb
can(:custom_ability, Person)
can(:controller_action, Person)
cannot(:read, Feedback) { |model| true }
# persons_controller.rb
def action
can?(:custom_ability, @person)
...
end
def controller_action
# checks automatically by cancan
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment