Mongoid: type of timestamps?

I am wondering why mongoid returns a String when I want to read the created_at date? my problem: when I want to print a date like this

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

rails raise

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

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

early!

+5
source share
1 answer

Your model contains

include Mongoid::Timestamps

If so, someObject.created_at.class should return Time

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

+17
source

All Articles