質問

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

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top