Adding ability authorizing in cancan

This commit is contained in:
Will Bradley 2012-09-02 04:45:42 -07:00
parent c80c3bbe5c
commit f3a05d64c1
3 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -1,4 +1,5 @@
class UsersController < ApplicationController class UsersController < ApplicationController
authorize_resource
before_filter :authenticate_user! before_filter :authenticate_user!
# GET /users # GET /users

View File

@ -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)