Commit 73557471 by liyijie

add policy_association_chain

parent 67f01625
......@@ -169,15 +169,21 @@ class SimpleController::BaseController < ::InheritedResources::Base
association
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)
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
after_association_chain(super)
origin_end_of_association_chain
end
end
def end_of_association_chain
after_association_chain(policy_association_chain)
end
def collection
get_collection_ivar || set_collection_ivar(
ransack_paginate(end_of_association_chain)
......
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