Skip to content

Instantly share code, notes, and snippets.

@mt9304
Created October 8, 2018 19:30
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 mt9304/f6aaa6e0b839aaf35450a85105728c14 to your computer and use it in GitHub Desktop.
Save mt9304/f6aaa6e0b839aaf35450a85105728c14 to your computer and use it in GitHub Desktop.
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.normal_user?
can :read, Book
can :create, Book
elsif user.admin?
can :manage, :all
else
can :read, Book
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment