簡體   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