Skip to content

Commit

Permalink
Added cancancan gem
Browse files Browse the repository at this point in the history
  • Loading branch information
Tejas Zambre committed Feb 15, 2020
1 parent ac63be4 commit 4fc3d35
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gem 'jbuilder', '~> 2.7'
# gem 'bcrypt', '~> 3.1.7'
gem 'simple_form'
gem 'devise', '~> 4.2'
gem 'cancancan'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
Expand Down Expand Up @@ -65,3 +66,4 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rubocop', '~> 0.79.0', require: false
gem 'haml', '~> 5.1', '>= 5.1.2'
gem 'overcommit'
gem 'rails-i18n'
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ GEM
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.1)
cancancan (3.0.2)
capybara (3.31.0)
addressable
mini_mime (>= 0.1.3)
Expand Down Expand Up @@ -161,6 +162,9 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-i18n (6.0.0)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 7)
railties (6.0.2.1)
actionpack (= 6.0.2.1)
activesupport (= 6.0.2.1)
Expand Down Expand Up @@ -272,6 +276,7 @@ PLATFORMS
DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
cancancan
capybara (>= 2.15)
database_cleaner
devise (~> 4.2)
Expand All @@ -284,6 +289,7 @@ DEPENDENCIES
pg (>= 0.18, < 2.0)
puma (~> 4.1)
rails (~> 6.0.2, >= 6.0.2.1)
rails-i18n
rspec-rails (~> 4.0.0.beta3)
rubocop (~> 0.79.0)
sass-rails (>= 6)
Expand Down
34 changes: 34 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

class Ability
include CanCan::Ability

def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
# can :manage, :all
# else
# can :read, :all
# end
#
# The first argument to `can` is the action you are giving the user
# permission to do.
# If you pass :manage it will apply to every action. Other common actions
# here are :read, :create, :update and :destroy.
#
# The second argument is the resource the user can perform the action on.
# If you pass :all it will apply to every resource. Otherwise pass a Ruby
# class of the resource.
#
# The third argument is an optional hash of conditions to further filter the
# objects.
# For example, here the user can only update published articles.
#
# can :update, Article, :published => true
#
# See the wiki for details:
# https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
end
end

0 comments on commit 4fc3d35

Please sign in to comment.