From 09976b458ba181f15028328a7607ba6073bd8335 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 28 May 2016 17:19:09 +0900 Subject: Reuse a result of `table.associated_table(column)` in `AssociationQueryHandler.value_for` --- .../relation/predicate_builder/association_query_handler.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb b/activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb index d7fd878265..413cb9fd84 100644 --- a/activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb +++ b/activerecord/lib/active_record/relation/predicate_builder/association_query_handler.rb @@ -2,13 +2,14 @@ module ActiveRecord class PredicateBuilder class AssociationQueryHandler # :nodoc: def self.value_for(table, column, value) - klass = if table.associated_table(column).polymorphic_association? && ::Array === value && value.first.is_a?(Base) + associated_table = table.associated_table(column) + klass = if associated_table.polymorphic_association? && ::Array === value && value.first.is_a?(Base) PolymorphicArrayValue else AssociationQueryValue end - klass.new(table.associated_table(column), value) + klass.new(associated_table, value) end def initialize(predicate_builder) -- cgit v1.2.3