1

I have Ruby 2.2.4 on Windows 10, both x64. I had a working Shopify Dashing gem, displaying everything until I tried to populate one of my widgets from a MySQL table.

I have followed Shopify Wiki's tutorial so my .rb file looks like this:

require 'mysql2'

# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
SCHEDULER.every '1s', :first_in => 0 do |job|
  send_event('response_time1', {value: (rand*400).to_i })
  send_event('response_time2', {value: (rand*400).to_i })


   # MySQL connection
  db = Mysql2::Client.new(:host => "127.0.0.1", :username => "root", :password => "root", :port => 3306, :database => "classicmodels" )

  # MySQL query
  sql = "SELECT jobTitle AS title , COUNT( jobTitle ) AS count FROM employees GROUP BY jobTitle ORDER BY COUNT(*) DESC LIMIT 0 , 5"

  # Execute the query
  results = db.query(sql)

  # Sending to List widget, so map to :label and :value
  acctitems = results.map do |row|
    row = {
      :label => row['title'],
      :value => row['count']
    }
  end

  # Update the List widget
  send_event('sql', { items: acctitems } )


end

It was a pain, but finally I have successfully installed mysql2 gem, or at least when I list gems, I can see it.

But now when I try to start Dashing, I get this error.

Can anybody help me to get this working?

luchaninov
  • 6,792
  • 6
  • 60
  • 75
kb29
  • 21
  • 2

1 Answers1

0

Posting this in answers instead of a comment because I am not high enough reputation. Did you include gem 'mysql2' in the Gemfile?

Kroden
  • 31
  • 3