Created
August 4, 2012 19:26
-
-
Save Kellyreid/3259476 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 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