class Array

def to_formatted_s(format = :default)

Blog.all.to_formatted_s(:db) # => "1,2,3"

id list:
Adding in the :db argument as the format yields a comma separated

Blog.all.to_formatted_s # => "First PostSecond PostThird Post"

to_formatted_s shows us:

Blog.all.map(&:title) #=> ["First Post", "Second Post", "Third post"]

end
end
title
def to_s
class Blog < ActiveRecord::Base

to_s on all elements and joining them. Having this model:
Converts a collection of elements into a formatted string by calling
def to_formatted_s(format = :default)
  case format
  when :db
    if empty?
      'null'
    else
      collect { |element| element.id }.join(',')
    end
  else
    to_default_s
  end
end