diff options
author | Kevin McPhillips <github@kevinmcphillips.ca> | 2016-06-28 14:54:17 -0400 |
---|---|---|
committer | Kevin McPhillips <github@kevinmcphillips.ca> | 2016-06-29 10:31:09 -0400 |
commit | a023fd665701cd455d9458e1b1a0cd0e550202aa (patch) | |
tree | b3d5ecd69d01c45351d6f6046e047c2484013256 /activerecord/lib | |
parent | 160cc331796ebfbcd6da83e96f391ab5732832b6 (diff) | |
download | rails-a023fd665701cd455d9458e1b1a0cd0e550202aa.tar.gz rails-a023fd665701cd455d9458e1b1a0cd0e550202aa.tar.bz2 rails-a023fd665701cd455d9458e1b1a0cd0e550202aa.zip |
Do not specal case inspecting associated arrays of over 10 elements, preventing infinite looping in some cases.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 10 |
1 files changed, 3 insertions, 7 deletions
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 <tt>#inspect</tt>-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 - # <tt>:db</tt> format, Array attributes are truncated up to 10 values. - # Other attributes return the value of <tt>#inspect</tt> without - # modification. + # <tt>:db</tt> format. Other attributes return the value of + # <tt>#inspect</tt> 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 |