trnc
trnc

Reputation: 21587

Mongoid: Type of timestamps strings?

i'm wondering why mongoid is returning a String when i want to read out the created_at date? my problem is: when i want to print the date like this

<% @app.created_at.strftime("%m/%d/%y") %>

rails is raising a

undefined method `getlocal' for "Wed, 11 Jul 2012 02:39:24 -0400":String

error. so what can i do to get mongoid to return the date as Time object?

thanks in advance!

Upvotes: 7

Views: 6126

Answers (1)

Shailen Tuli
Shailen Tuli

Reputation: 14191

Does your model contain a

include Mongoid::Timestamps

If it is, someObject.created_at.class should return Time

See http://mongoid.org/en/mongoid/docs/extras.html#timestamps

Upvotes: 21

Related Questions