Add this to your Gemfile:
gem 'cancancan'and run the bundle install command.
Use the provided command to generate a template for your abilities file:
rails generate cancan:abilityThis will generate the following file:
# /app/models/ability.rb
class Ability
include CanCan::Ability
def initialize(user)
end
endThis is everything you need to start. 馃挜
All the permissions will be defined in this file. You can of course split it into multiple files if your application grows, but we'll cover that in a later chapter.
Let's now start with the basic concepts: define and check abilities.