Flowdock

Notes posted by etmoyo

RSS feed
June 23, 2011
0 thanks

RE: Don't Use to_formatted_s(:db) on an Array of IDs

The reason it doesnt work @joshuapinter for IDs is because if you look at the source:

case format
  when :db
    if respond_to?(:empty?) && self.empty?
      "null"
    else
      collect { |element| element.id }.join(",") # look at this line
    end
  else
    to_default_s
end

It maps/collects the object ids and then joins them using a comma ; so in the case of 60 for instance :

60.object_id #=> 121

60.id #=> 121