i use rails 3.2.6, ruby 1.9.3 with the mongoid gem 3.0.
i want to display the created_at field of a database entry, but get the following error:
undefined method `getlocal' for "Wed, 25 Apr 2012 15:04:37 -0400":String
here's the rails code:
<dt>Erstellt am:</dt><dd><%= @app.created_at %></dd>
any advice what's the problem? is there a bugfix? should work in my opinion?
thanks in advance!
try adding the following to your model
include Mongoid::Timestamps
see http://mongoid.org/en/mongoid/docs/extras.html#timestamps
getlocal
is a method on the Time class, so it may be a problem of intermixing object types. The system is expecting the @app.created_at
to be an instance of Time, not DateTime. Make sure the field type for created_at
is DateTime and that when creating/updating this field, make sure the object you put in is also a DateTime object.
if you use mongoid, instead of
@app.created_at
try
@app[:created_at]
this worked for me