I''m froma Spain, and was using DATE_FORMATS to allow correct spanish
format of date values. I''m using this at environment.rb file:
ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS[:default]
= ''%d-%m-%Y''
But using serialize of attributes in ActiveRecord classes give me
problems. I have a simple model like that:
class History < ActiveRecord::Base
serialize :changes
end
Doing this:
History.create({:changes=>{:my_date=>Date.today}})
I can''t read changes attribute like an Hash object, it always return a
String object.
Digging deeper,..., I have found that the problem resides on the YAML
library and the format of Date type.
Doing this:
Date.today.to_yaml
=> "--- !timestamp 05-06-2008\n"
But doing this:
YAML.load(Date.today.to_yaml)
ArgumentError: argument out of range
from /usr/lib/ruby/1.8/yaml.rb:133:in `utc''
from /usr/lib/ruby/1.8/yaml.rb:133:in `node_import''
from /usr/lib/ruby/1.8/yaml.rb:133:in `load''
from /usr/lib/ruby/1.8/yaml.rb:133:in `load''
from (irb):1
Reading the YAML Cookbook at http://yaml4r.sourceforge.net/co...
I have found that YAML needs Date to be represented by its year, month
and day in ISO8601 order.
¿Why in Rails the YAML/Serialize method don''t uses my date format?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---