By default, the datetime field from the database is converted and deletes milliseconds:
some_datetime => "2009-11-11T02: 19: 36Z"
attribute_before_type_cast ('some_datetime') => "2009-11-11 02:19: 36.145"
If I try to override the accessor for this attribute, for example:
def some_datetime
attribute_before_type_cast('some_datetime')
end
when I try to use "to_xml" for this model, I get the following error:
NoMethodError method (undefined`xmlschema 'for "2009-11-11 02:19: 36,145": String):
I tried to parse a String to Time object, but I can't get it to turn on milliseconds;
def some_datetime
Time.parse(attribute_before_type_cast('some_datetime').sub(/\s/,"T").sub(/$/,"Z"))
end
Can someone help get a datetime with milliseconds represented by to_xml?