I have a question object with a created_at attribute in it. When I will find a question i get back the created_at from the REST service, but Activeresource do not convert the date string to DateTime.
Question.find(1)
/questions/1.json
Question.find(1).created_at.class
=> String
In which format should be the Json response, so that ActiveResource will convert it to a DateTime?
If it is not possible, what should i do?
According to slide #14 in this presentation, you can do this in config/initializers/active_resource.rb
:
ActiveSupport::JSON::Encoding.use_standard_json_time_format = true
ActiveSupport.parse_json_times = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With