自从我更新为ruby 1.9.2p0 (2010-08-18 revision 29036)
& Rails 3.0.1
。我该如何解决?
undefined method `getlocal' for Sat, 30 Oct 2010 08:32:42 +0000:DateTime
activesupport (3.0.1) lib/active_support/time_with_zone.rb:75:in `localtime'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/quoting.rb:65:in `quoted_date'
activerecord (3.0.1) lib/active_record/connection_adapters/sqlite_adapter.rb:125:in `quoted_date'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/quoting.rb:31:in `quote'
感谢阅读。
编辑:
application.rb中
config.time_zone = 'Brisbane'
config.active_record.default_timezone = 'Brisbane'
答案 0 :(得分:1)
那是行不通的,
对于Time类,定义了getlocal方法,而不是DateTime类(在您的情况下,对象是DateTime对象)。
DateTime#to_time不是将DateTime对象转换为Time对象的完整校对解决方案。
请查看下面的链接,了解有关如何将DateTime对象转换为Time对象的详细信息
Convert to/from DateTime and Time in Ruby
希望有所帮助