Skip to content

Instantly share code, notes, and snippets.

@LRDesign
Created January 21, 2013 19:47
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 LRDesign/4588699 to your computer and use it in GitHub Desktop.
Save LRDesign/4588699 to your computer and use it in GitHub Desktop.
The kind of thing that happens when you don't TDD... At least this class works the *second* time you instantiate it...
class Ability
include CanCan::Ability
def initialize(user)
def initialize(user)
user ||= User.new # guest user (not logged in)
# abilities defined here
if user.role == "admin"
# abilities defined here
end
if user.role == "super"
# abilities defined here
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment