lib/cancannible/grantee.rb in cancannible-1.0.0 vs lib/cancannible/grantee.rb in cancannible-1.0.1

- old
+ new

@@ -104,14 +104,19 @@ module Cancannible # This module is automatically included into all controllers. # It overrides some CanCan ControllerAdditions module ControllerAdditions + # Returns abilities cached in the current_user model. + # If that fails, returns a default Ability instance def current_ability - current_user.try(:abilities) + current_user.try(:abilities) || if ability_class = ('::Ability'.constantize rescue nil) + ability_class.new(current_user) + end end end end + if defined? ActionController::Base ActionController::Base.class_eval do include Cancannible::ControllerAdditions end