繁体   English   中英

ActiveRecord> MySQL适配器>未定义的方法“ more_results”

[英]ActiveRecord > MySQL Adapter > undefined method `more_results'

我已经将ActiveRecord合并到我正在编写的脚本中,以处理MySQL数据库中的某些数据。 在我的开发环境中,使用Mac OS X,一切正常,但是,当我尝试在Linux环境中部署脚本时,始终出现以下错误:

/activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb:623:in `select': undefined method `more_results' for #<Mysql:0x915976c> (NoMethodError)

发生此错误的代码粘贴在下面,特别是已注释的倒数第二行。

  def select(sql, name = nil)
    @connection.query_with_result = true
    result = execute(sql, name)
    rows = []
    result.each_hash { |row| rows << row }
    result.free
    @connection.more_results && @connection.next_result   # invoking stored procedures with CLIENT_MULTI_RESULTS requires this to tidy up else connection will be dropped 
    rows
  end

可以在https://rails.lighthouseapp.com/projects/8994/tickets/3151-mysql-adapter-update-to-enable-use-of-stored-procedures#ticket-中查看引入此代码的历史。 3151-33

就是说,我仍然不确定如何解决此错误,而不必仅注释掉有问题的行。 我没有使用任何存储过程,因此这不是一个重要的问题,但是,我想实施一个更可扩展的修复程序。

我在两种环境中都使用以下宝石。

activerecord(3.0.0)MySQL(2.8.1)

预先感谢您对这里可能发生的任何想法!

我是Ruby(ha)的新手,在学习本教程时遇到了相同的问题:在步骤6.1(迁移)中, http//guides.rubyonrails.org/getting_started.html

我只是将命令包装在if中,以确保在调用该方法之前该方法确实存在,如下所示:

if (@connection.respond_to?('more_results'))
      @connection.more_results && @connection.next_result    # invoking stored procedures with CLIENT_MULTI_RESULTS requires this to tidy up else connection will be dropped 
end

然后,我就可以顺利完成本教程。 我不知道跳过那行代码的含义是什么,但是在我的小开发盒中,这可能并不重要。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM