aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/join_dependency/join_association.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/join_dependency/join_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb12
1 files changed, 2 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
index 95f16c622e..70520b8e85 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -40,21 +40,13 @@ module ActiveRecord
constraint = build_constraint(klass, table, key, foreign_table, foreign_key)
- rel = reflection.join_scope(table)
+ rel = reflection.join_scope(table, foreign_klass)
- if rel && !rel.arel.constraints.empty?
+ if rel.arel.constraints.any?
binds += rel.bound_attributes
constraint = constraint.and rel.arel.constraints
end
- if reflection.type
- value = foreign_klass.base_class.name
- column = klass.columns_hash[reflection.type.to_s]
-
- binds << Relation::QueryAttribute.new(column.name, value, klass.type_for_attribute(column.name))
- constraint = constraint.and klass.arel_attribute(reflection.type, table).eq(Arel::Nodes::BindParam.new)
- end
-
joins << table.create_join(table, table.create_on(constraint), join_type)
# The current table in this iteration becomes the foreign table in the next