aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array
diff options
context:
space:
mode:
authorAlvaro Pereyra <alvaro@xendacentral.com>2012-05-28 02:25:05 -0500
committerAlvaro Pereyra <alvaro@xendacentral.com>2012-05-28 02:27:23 -0500
commit422d3a4f042df8ea4bd42b0dca38a295a218c376 (patch)
tree665d54be3f808aeb154aeb3baa61460b20bf99be /activesupport/lib/active_support/core_ext/array
parentda4252f4a16bd3166866201a852f938263a3225c (diff)
downloadrails-422d3a4f042df8ea4bd42b0dca38a295a218c376.tar.gz
rails-422d3a4f042df8ea4bd42b0dca38a295a218c376.tar.bz2
rails-422d3a4f042df8ea4bd42b0dca38a295a218c376.zip
Updates documentation with cleaner examples and texts [ci skip]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index 193388a158..d5735dd7eb 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -39,7 +39,19 @@ class Array
end
# Converts a collection of elements into a formatted string by calling
- # <tt>to_s</tt> on all elements and joining them:
+ # <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"
#
@@ -47,6 +59,7 @@ class Array
# id list:
#
# Blog.all.to_formatted_s(:db) # => "1,2,3"
+
def to_formatted_s(format = :default)
case format
when :db