Ruby 无法根据 Nil 确定时区(参数错误)
Ruby Cannot Determine Timezone From Nil (Argument Error)
我用 ruby 写了一些代码。当我尝试 运行 代码时出现此错误:
/Users/macbook/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.3.3/lib/rufus/scheduler/zotime.rb:41:
in `initialize':
cannot determine timezone from nil (etz:nil,tnz:"+03",tzid:nil) (ArgumentError)
编辑:
我正在使用电子书 gem。我只添加了消费者密钥和访问令牌。我的 .rb 文件是:
require 'twitter_ebooks'
class MyBot < Ebooks::Bot
def configure
self.consumer_key = 'Consumer Key'
self.consumer_secret = 'Consumer Secret'
self.blacklist = ['tnietzschequote']
self.delay_range = 1..6
end
def on_startup
scheduler.every '24h' do
end
end
def on_message(dm)
end
def on_follow(user)
end
def on_mention(tweet)
end
def on_timeline(tweet)
end
def on_favorite(user, tweet)
end
def on_retweet(tweet)
end
end
MyBot.new("twitter_id") do |bot|
bot.access_token = "Access Token" # Token connecting the app to this account
bot.access_token_secret = "Access Token Secret"
end
如果有人帮助我,我会很高兴。
这就是全部代码了吗?
我 运行 它对我来说效果很好。
mb = MyBot.new("twitter_id") do |bot|
bot.access_token = "Access Token" # Token connecting the app to this account
bot.access_token_secret = "Access Token Secret"
end
p mb.access_token
p mb.access_token_secret
这两个都产生了适当的值。
错误说第 41 行有问题,但您发布的代码不是第 41 行。也许更多信息可以帮助...
在调度程序实例化之前明确设置 ENV['TZ']
ENV['TZ'] = 'Asia/Shanghai' # your time zone
# or
ENV['TZ'] = Time.zone.tzinfo.identifier
scheduler = Rufus::Scheduler.new
# ...
应该可以解决您的问题:)
我用 ruby 写了一些代码。当我尝试 运行 代码时出现此错误:
/Users/macbook/.rvm/gems/ruby-2.2.2/gems/rufus-scheduler-3.3.3/lib/rufus/scheduler/zotime.rb:41:
in `initialize':
cannot determine timezone from nil (etz:nil,tnz:"+03",tzid:nil) (ArgumentError)
编辑:
我正在使用电子书 gem。我只添加了消费者密钥和访问令牌。我的 .rb 文件是:
require 'twitter_ebooks'
class MyBot < Ebooks::Bot
def configure
self.consumer_key = 'Consumer Key'
self.consumer_secret = 'Consumer Secret'
self.blacklist = ['tnietzschequote']
self.delay_range = 1..6
end
def on_startup
scheduler.every '24h' do
end
end
def on_message(dm)
end
def on_follow(user)
end
def on_mention(tweet)
end
def on_timeline(tweet)
end
def on_favorite(user, tweet)
end
def on_retweet(tweet)
end
end
MyBot.new("twitter_id") do |bot|
bot.access_token = "Access Token" # Token connecting the app to this account
bot.access_token_secret = "Access Token Secret"
end
如果有人帮助我,我会很高兴。
这就是全部代码了吗? 我 运行 它对我来说效果很好。
mb = MyBot.new("twitter_id") do |bot|
bot.access_token = "Access Token" # Token connecting the app to this account
bot.access_token_secret = "Access Token Secret"
end
p mb.access_token
p mb.access_token_secret
这两个都产生了适当的值。
错误说第 41 行有问题,但您发布的代码不是第 41 行。也许更多信息可以帮助...
在调度程序实例化之前明确设置 ENV['TZ']
ENV['TZ'] = 'Asia/Shanghai' # your time zone
# or
ENV['TZ'] = Time.zone.tzinfo.identifier
scheduler = Rufus::Scheduler.new
# ...
应该可以解决您的问题:)