class Post
serialize :many_dates, Array
end
Now in rails console
> Post.create!(:many_dates => [Date.today, Date.tomorrow])
> Post.last.many_dates
=> [Tue, 07 Feb 2012, Wed, 08 Feb 2012]
> Date::DATE_FORMATS[:default] = "%d-%b-%Y"
> Post.create!(:many_dates => [Date.today, Date.tomorrow])
> Post.last.many_dates
=> "--- \n- !timestamp 07-Feb-2012\n- !timestamp 08-Feb-2012\n"
Output of Post.last.many_dates, sometimes it returns String (like above) and sometimes raises ActiveRecord::SerializationTypeMismatch
Tested with Rails 3.1.1, 3.1.3 and 3.2.1 on ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
This issue was also reported in June 2008 at https://rails.lighthouseapp.com/projects/8994/tickets/340-yaml-activerecord-serialize-and-date-formats-problem