Undefined method "getlocal" when displaying created_at?

i use rails 3.2.6, ruby ​​1.9.3 with mongoid gemstone 3.0.

I want to display the created_at field of a database record, but get the following error:

undefined method `getlocal' for "Wed, 25 Apr 2012 15:04:37 -0400":String 

here is the rails code:

 <dt>Erstellt am:</dt><dd><%= @app.created_at %></dd> 

any advice what is the problem? is there a fix should work in my opinion?

early!

+4
source share
3 answers

getlocal is a method of the Time class, so this may be a problem of mixing object types. The system expects @app.created_at be an instance of Time, not DateTime . Make sure that the field type for created_at is DateTime and that when creating / updating this field, make sure that the object you entered is also a DateTime object.

+1
source

try adding the following to your model:

 include Mongoid::Timestamps 

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

+1
source

if you use mangoid, not @app.created_at
to try
@app[:created_at]
it worked for me

0
source

All Articles