aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array/conversions.rb
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-07-11 18:13:43 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-07-11 18:21:11 +0900
commit5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13 (patch)
tree21f12f0e9658688377ab1371e3f21536f56a683d /activesupport/lib/active_support/core_ext/array/conversions.rb
parent3c90f7a25870524fc980d746e85c440e693c0a63 (diff)
downloadrails-5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13.tar.gz
rails-5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13.tar.bz2
rails-5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13.zip
Array#to_formatted_s does not call each element's to_s anymore
Array#to_s calls each element's inspect since ruby 1.9
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb19
1 files changed, 2 insertions, 17 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index 3807ee63b1..76ffd23ed1 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -82,23 +82,8 @@ class Array
end
end
- # Converts a collection of elements into a formatted string by calling
- # <tt>to_s</tt> on all elements and joining them. Having this model:
- #
- # class Blog < ActiveRecord::Base
- # def to_s
- # title
- # end
- # end
- #
- # Blog.all.map(&:title) #=> ["First Post", "Second Post", "Third post"]
- #
- # <tt>to_formatted_s</tt> shows us:
- #
- # Blog.all.to_formatted_s # => "First PostSecond PostThird Post"
- #
- # Adding in the <tt>:db</tt> argument as the format yields a comma separated
- # id list:
+ # Extends <tt>Array#to_s</tt> to convert a collection of elements into a
+ # comma separated id list if <tt>:db</tt> argument is given as the format.
#
# Blog.all.to_formatted_s(:db) # => "1,2,3"
def to_formatted_s(format = :default)