diff --git a/lib/cancan/model_adapters/active_record_adapter.rb b/lib/cancan/model_adapters/active_record_adapter.rb index f20da17..3cc55a4 100644 --- a/lib/cancan/model_adapters/active_record_adapter.rb +++ b/lib/cancan/model_adapters/active_record_adapter.rb @@ -165,6 +165,8 @@ module CanCan end end -ActiveRecord::Base.class_eval do - include CanCan::ModelAdditions +ActiveSupport.on_load(:active_record) do + ActiveRecord::Base.class_eval do + include CanCan::ModelAdditions + end end diff --git a/lib/cancan/model_additions.rb b/lib/cancan/model_additions.rb index 0f32d36..3f4404e 100644 --- a/lib/cancan/model_additions.rb +++ b/lib/cancan/model_additions.rb @@ -2,6 +2,8 @@ module CanCan # This module adds the accessible_by class method to a model. It is included in the model adapters. module ModelAdditions + extend ActiveSupport::Concern + module ClassMethods # Returns a scope which fetches only the records that the passed ability # can perform a given action on. The action defaults to :index. This @@ -23,9 +25,5 @@ module CanCan ability.model_adapter(self, action).database_records end end - - def self.included(base) - base.extend ClassMethods - end end end