Skip to content

Instantly share code, notes, and snippets.

@Kellyreid
Created August 4, 2012 19:26
Show Gist options
  • Save Kellyreid/3259476 to your computer and use it in GitHub Desktop.
Save Kellyreid/3259476 to your computer and use it in GitHub Desktop.
class Ability
include CanCan::Ability
def initialize user, options = {}
if !user
can :read, :all
end
if user.has_role? :admin
can :manage, :all
end
if user.has_role? :free
can :manage, Measurement do |measurement|
measurement.try(:user) == user
end #do
can :create, Measurement
end #if
end #def
end #class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment