Question

Im trying to save date time information to the following field in mongo

key :last_comment_time_cache, DateTime

update_attributes!({:last_comment_time_cache => Time.now}) 

The data that is being saved is missing the time

"last_comment_time_cache": {
    "$date": "2013-03-23T00:00:00.000Z"
}

Any ideas on what im doing wrong?, Thanks Nath

Was it helpful?

Solution

Try changing the field type to Time instead of DateTime. If you watch their Date extension here (Date is the parent of DateTime) they are only taking day,month and year into account to construct the date that will be sent to mongo, that's not the case for their Time implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top