Permalink
Browse files

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
  • Loading branch information...
1 parent 3c90f7a commit 5ff00fcd3d3c4229246bf8ef749b6bc27a5cdb13 @amatsuda amatsuda committed Jul 11, 2013
Showing with 2 additions and 17 deletions.
  1. +2 −17 activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -82,23 +82,8 @@ def to_sentence(options = {})
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)

0 comments on commit 5ff00fc

Please sign in to comment.