【问题标题】:Dashing and mySQL with Ruby on Windows在 Windows 上使用 Ruby 进行 Dashing 和 mySQL
【发布时间】:2016-04-05 12:19:15
【问题描述】:

我在 Windows 10 上安装了 Ruby 2.2.4,都是 x64。我有一个可用的 Shopify Dashing gem,显示所有内容,直到我尝试从 MySQL 表中填充我的一个小部件。

我已按照 Shopify Wiki 的教程进行操作,因此我的 .rb 文件如下所示:

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

这很痛苦,但最后我已经成功安装了 mysql2 gem,或者至少在我列出 gems 时,I can see it

但是现在当我尝试启动 Dashing 时,我得到了 this error

有人可以帮我完成这项工作吗?

【问题讨论】:

    标签: ruby mysql2 dashing


    【解决方案1】:

    在答案而不是评论中发布此内容,因为我的声誉不够高。您是否在 Gemfile 中包含了gem 'mysql2'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-08
      • 1970-01-01
      • 2010-11-04
      • 2010-12-07
      相关资源
      最近更新 更多