後我關於Ruby 2.2.1並active_support 4.2安裝,所以我想用未定義的方法`zone`的時間:類需要active_support/time_with_zone
Time.zone.parse('2007-02-10 15:30:45')
如下所述:http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html
但即使在要求active_support
和active_support/time_with_zone
之後,我似乎仍然不能使用Time.zone
。觀察:
2.2.1 :002 > require "active_support"
=> true
2.2.1 :003 > Time.zone
NoMethodError: undefined method `zone' for Time:Class
2.2.1 :004 > require "active_support/time_with_zone"
=> true
2.2.1 :005 > Time.zone
NoMethodError: undefined method `zone' for Time:Class
發生了什麼事?
謝謝!這就說得通了! – User314159