Adding ability authorizing in cancan
This commit is contained in:
parent
c80c3bbe5c
commit
f3a05d64c1
|
@ -1,4 +1,5 @@
|
||||||
class DoorLogsController < ApplicationController
|
class DoorLogsController < ApplicationController
|
||||||
|
authorize_resource
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
# GET /door_logs
|
# GET /door_logs
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
authorize_resource
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
# GET /users
|
# GET /users
|
||||||
|
|
|
@ -2,6 +2,9 @@ class Ability
|
||||||
include CanCan::Ability
|
include CanCan::Ability
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
|
can :manage, User do |u|
|
||||||
|
u.id == user.id
|
||||||
|
end
|
||||||
# Define abilities for the passed in user here. For example:
|
# Define abilities for the passed in user here. For example:
|
||||||
#
|
#
|
||||||
# user ||= User.new # guest user (not logged in)
|
# user ||= User.new # guest user (not logged in)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user