尝试创建客户端时出现“未初始化常量”错误

“Uninitialized constant” error when trying to create Client

我正在处理 dashing 仪表板并尝试添加一个 Jira widget.In 它正在尝试创建和初始化客户端对象的小部件代码。如下代码所示

require  'Jira'

SCHEDULER.every '5m', :first_in => 0 do |job|
  client = Jira::Client.new({
    :username => ENV['Talal'],
    :password => ENV['Talal123'],
    :site => "http://192.168.99.100:32768",
    :auth_type => :basic,
    :context_path => "/jira"
  })

但是当我到达这一行时 client = Jira::Client.new。发生异常,指出 uninitialized constant Jira::Client.

我认为您应该使用的 gem 是 jira-ruby。一旦你安装它,Bundler 应该会自动为你需要它,这意味着如果你在 Rails 环境中,你不需要做 require 'Jira'.

如果您不希望它在整个应用程序范围内都需要,顺便说一句,您应该将其添加到您的 Gemfile 中:

gem 'jira-ruby', require: false

# then in your scheduler, you have to explicitly require it as before:
require 'jira-ruby'

SCHEDULER.every '5m', :first_in => 0 do |job|
  client = Jira::Client.new({
    :username => ENV['Talal'],
    :password => ENV['Talal123'],
    :site => "http://192.168.99.100:32768",
    :auth_type => :basic,
    :context_path => "/jira"
  })

额外information here