Permalink
Browse files

Merge pull request #751 from mculp/2.0

fixes #750 - load hooks return ActiveRecord::Model in Rails 4, use Concern
  • Loading branch information...
ryanb committed Sep 29, 2012
2 parents aed9f26 + 9550154 commit f1cebde51a87be149b4970a3287826bb63c0ac0b
Showing with 6 additions and 6 deletions.
  1. +4 −2 lib/cancan/model_adapters/active_record_adapter.rb
  2. +2 −4 lib/cancan/model_additions.rb
@@ -165,6 +165,8 @@ def clean_joins(joins_hash)
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
@@ -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 @@ def accessible_by(ability, action = :index)
ability.model_adapter(self, action).database_records
end
end
-
- def self.included(base)
- base.extend ClassMethods
- end
end
end

0 comments on commit f1cebde

Please sign in to comment.