开发者

undefined method `getlocal' for Sat, 30 Oct 2010 08:32:42 +0000:DateTime with Ruby 1.9.2

I'm getting this error since I updated to ruby 1.9.2p0 (2010-08-18 rev开发者_如何学编程ision 29036) & Rails 3.0.1. How can I fix it?

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'

Thanks for reading.

EDIT:

application.rb

config.time_zone = 'Brisbane'
config.active_record.default_timezone = 'Brisbane'


Yeh that won't work,

The getlocal method is defined, for the Time class, and not for the DateTime class ( the object in your case is a DateTime object ).

DateTime#to_time is not a full proof solution to convert a DateTime Object to Time object.

Take a look at the link below for details on how to convert a DateTime object to a Time object

Convert to/from DateTime and Time in Ruby

Hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜