diff --git a/lib/ransack/adapters/active_record/context.rb b/lib/ransack/adapters/active_record/context.rb index 48a6ea80..e28fd812 100644 --- a/lib/ransack/adapters/active_record/context.rb +++ b/lib/ransack/adapters/active_record/context.rb @@ -110,7 +110,7 @@ def klassify(obj) # def join_sources base, joins = begin - alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, []) + alias_tracker = @object.alias_tracker constraints = @join_dependency.join_constraints(@object.joins_values, alias_tracker, @object.references_values) [ @@ -278,7 +278,7 @@ def build_joins(relation) join_list = join_nodes + convert_join_strings_to_ast(relation.table, string_joins) - alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, relation.table.name, join_list) + alias_tracker = relation.alias_tracker(join_list) join_dependency = Polyamorous::JoinDependency.new(relation.klass, relation.table, association_joins, Arel::Nodes::OuterJoin) join_dependency.instance_variable_set(:@alias_tracker, alias_tracker) join_nodes.each do |join|