gpt4 book ai didi

ruby-on-rails - 奇怪的未初始化常量错误(Rails)

转载 作者:行者123 更新时间:2023-12-04 19:54:34 24 4
gpt4 key购买 nike

下面的代码

class Schedule < ActiveRecord::Base     
def self.get
today = TZInfo::Timezone.get('America/New_York').utc_to_local(Time.now.utc).to_date
end
end

产生以下错误:

uninitialized constant Schedule::TZInfo

但仅当我从脚本/控制台运行它时。想法?

(另外,有没有更好的方法来获取给定时区的当前日期?)

最佳答案

你试过添加

require 'tzinfo'

关于ruby-on-rails - 奇怪的未初始化常量错误(Rails),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1236694/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com