Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 598
trnc Avatar asked Jul 11 '12 07:07

trnc


1 Answers

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

like image 70
Shailen Tuli Avatar answered Sep 21 '22 22:09

Shailen Tuli