潇洒 - 未初始化的恒定Nokogiri异常

Ada*_*abi 1 ruby sinatra nokogiri rufus-scheduler gemfile

当我尝试开始潇洒时,我收到以下错误:

scheduler caught exception:
uninitialized constant Nokogiri
/Users/Adam/projects/ticker/jobs/sample.rb:2:in `block in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

我的Gemfile是:

source 'https://rubygems.org'

gem 'nokogiri'
gem 'dashing'
Run Code Online (Sandbox Code Playgroud)

我的jobs文件夹包含一个文件夹sample.rb:

SCHEDULER.every '2s' do
  oil_doc = Nokogiri::HTML(open("http://www.bloomberg.com/energy/"))
  a = oil_doc.css("table.std_table_module").first
  price = a.xpath("//td[3]").first.children.text
  send_event('valuation', { current: price })
end
Run Code Online (Sandbox Code Playgroud)

我已经尝试添加 require 'open-uri'到Gemfile和sample.rb但它没有帮助!

Dav*_*kin 5

错误信息是说它不知道任何事情Nokogiri,这是nokogiri gem中定义的模块.为了将其纳入范围,您需要添加:

require 'nokogiri'
Run Code Online (Sandbox Code Playgroud)

到你的sample.rb(通常在文件的顶部).