From a023fd665701cd455d9458e1b1a0cd0e550202aa Mon Sep 17 00:00:00 2001 From: Kevin McPhillips Date: Tue, 28 Jun 2016 14:54:17 -0400 Subject: Do not specal case inspecting associated arrays of over 10 elements, preventing infinite looping in some cases. --- activerecord/lib/active_record/attribute_methods.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'activerecord/lib/active_record/attribute_methods.rb') diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 1fb5eb28cd..78bfcf34a9 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -279,9 +279,8 @@ module ActiveRecord # Returns an #inspect-like string for the value of the # attribute +attr_name+. String attributes are truncated up to 50 # characters, Date and Time attributes are returned in the - # :db format, Array attributes are truncated up to 10 values. - # Other attributes return the value of #inspect without - # modification. + # :db format. Other attributes return the value of + # #inspect without modification. # # person = Person.create!(name: 'David Heinemeier Hansson ' * 3) # @@ -292,7 +291,7 @@ module ActiveRecord # # => "\"2012-10-22 00:15:07\"" # # person.attribute_for_inspect(:tag_ids) - # # => "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]" + # # => "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]" def attribute_for_inspect(attr_name) value = read_attribute(attr_name) @@ -300,9 +299,6 @@ module ActiveRecord "#{value[0, 50]}...".inspect elsif value.is_a?(Date) || value.is_a?(Time) %("#{value.to_s(:db)}") - elsif value.is_a?(Array) && value.size > 10 - inspected = value.first(10).inspect - %(#{inspected[0...-1]}, ...]) else value.inspect end -- cgit v1.2.3