未定义的方法"getlocal"显示created_at时? [英] Undefined method "getlocal" when displaying created_at?
问题描述
我将rails 3.2.6和ruby 1.9.3与mongoid gem 3.0一起使用.
i use rails 3.2.6, ruby 1.9.3 with the mongoid gem 3.0.
我想显示数据库条目的created_at字段,但出现以下错误:
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
这是rails代码:
<dt>Erstellt am:</dt><dd><%= @app.created_at %></dd>
任何建议是什么问题?是否有错误修正?我认为应该可行?
any advice what's the problem? is there a bugfix? should work in my opinion?
提前谢谢!
推荐答案
getlocal
是 Time 类的方法,因此可能是混合对象类型的问题.系统期望@app.created_at
是Time的实例,不是DateTime .确保created_at
的字段类型为DateTime,并且在创建/更新此字段时,请确保您输入的对象也是DateTime对象.
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.
这篇关于未定义的方法"getlocal"显示created_at时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!