class Array

def to_fs(format = :default)

[1,2].to_fs # => "[1, 2]"
Blog.none.to_fs(:db) # => "null"
Blog.all.to_fs(:db) # => "1,2,3"

This method is aliased to to_formatted_s.

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_fs(format = :default)
  case format
  when :db
    if empty?
      "null"
    else
      collect(&:id).join(",")
    end
  else
    to_s
  end
end