From 5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 11 Jul 2013 18:13:43 +0900 Subject: 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 --- .../lib/active_support/core_ext/array/conversions.rb | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'activesupport/lib') 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 - # to_s 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"] - # - # to_formatted_s shows us: - # - # Blog.all.to_formatted_s # => "First PostSecond PostThird Post" - # - # Adding in the :db argument as the format yields a comma separated - # id list: + # Extends Array#to_s to convert a collection of elements into a + # comma separated id list if :db argument is given as the format. # # Blog.all.to_formatted_s(:db) # => "1,2,3" def to_formatted_s(format = :default) -- cgit v1.2.3