adding 'cannot?' method which performs opposite check of 'can?' - closes #1
This commit is contained in:
@@ -21,6 +21,10 @@ module CanCan
|
||||
false
|
||||
end
|
||||
|
||||
def cannot?(*args)
|
||||
!can?(*args)
|
||||
end
|
||||
|
||||
def possible_actions_for(initial_action)
|
||||
actions = [initial_action]
|
||||
(@aliased_actions || default_alias_actions).each do |target, aliases|
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module CanCan
|
||||
module ControllerAdditions
|
||||
def self.included(base)
|
||||
base.helper_method :can?
|
||||
base.helper_method :can?, :cannot?
|
||||
end
|
||||
|
||||
def unauthorized!
|
||||
@@ -16,6 +16,10 @@ module CanCan
|
||||
(@current_ability ||= current_ability).can?(*args)
|
||||
end
|
||||
|
||||
def cannot?(*args)
|
||||
(@current_ability ||= current_ability).cannot?(*args)
|
||||
end
|
||||
|
||||
def load_resource # TODO this could use some refactoring
|
||||
unless params[:action] == "index"
|
||||
if params[:id]
|
||||
|
||||
Reference in New Issue
Block a user