class Array

def to_formatted_s(format = :default)

[1,2].to_formatted_s # => "[1, 2]"
Blog.none.to_formatted_s(:db) # => "null"
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(&:id).join(',')
    end
  else
    to_default_s
  end
end