Commit 73557471 by liyijie

add policy_association_chain

parent 67f01625
...@@ -169,13 +169,19 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -169,13 +169,19 @@ class SimpleController::BaseController < ::InheritedResources::Base
association association
end end
def end_of_association_chain alias_method :origin_end_of_association_chain, :end_of_association_chain
def policy_association_chain
policy_class ||= self.class.instance_variable_get(:@policy_class) policy_class ||= self.class.instance_variable_get(:@policy_class)
if policy_class.present? && scope_policy_class = "#{policy_class}::Scope".safe_constantize if policy_class.present? && scope_policy_class = "#{policy_class}::Scope".safe_constantize
after_association_chain(scope_policy_class.new(current_user, super).resolve) scope_policy_class.new(current_user, origin_end_of_association_chain).resolve
else else
after_association_chain(super) origin_end_of_association_chain
end
end end
def end_of_association_chain
after_association_chain(policy_association_chain)
end end
def collection def collection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment