class Array

def to_formatted_s(format = :default)

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

comma separated id list if :db argument is given as the format.
Extends Array#to_s to convert a collection of elements into a
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