ruby-on-railsjiradashing

“Uninitialized constant” error when trying to create Client


I am working on dashing dashboard and trying to add a Jira widget.In the widget code it is trying to create and initialize a Client object. As shown in code below

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"
  })

But as I gets to this line client = Jira::Client.new. An exception occurs which states that uninitialized constant Jira::Client.


Solution

  • I believe the gem you should be using is jira-ruby. Once you install it, Bundler should automatically require it for you, meaning if you're in a Rails environment, you shouldn't need to do require 'Jira'.

    If you don't want it required application-wide, BTW, you should add this to your 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"
      })
    

    Additional information here