load hooks return ActiveRecord::Model in Rails 4, use Concern
This commit is contained in:
parent
aed9f26e56
commit
9550154b09
|
@ -165,6 +165,8 @@ module CanCan
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ActiveRecord::Base.class_eval do
|
ActiveSupport.on_load(:active_record) do
|
||||||
|
ActiveRecord::Base.class_eval do
|
||||||
include CanCan::ModelAdditions
|
include CanCan::ModelAdditions
|
||||||
|
end
|
||||||
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.
|
# This module adds the accessible_by class method to a model. It is included in the model adapters.
|
||||||
module ModelAdditions
|
module ModelAdditions
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
# Returns a scope which fetches only the records that the passed ability
|
# Returns a scope which fetches only the records that the passed ability
|
||||||
# can perform a given action on. The action defaults to :index. This
|
# 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
|
ability.model_adapter(self, action).database_records
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.included(base)
|
|
||||||
base.extend ClassMethods
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user