簡體   English   中英

NoMethodError:#的未定義方法`more_results&#39; <Mysql>

[英]NoMethodError: undefined method `more_results' for #<Mysql>

我正在嘗試創建rake任務以從舊的php應用程序導入數據。但是,當我在rails控制台上運行Old :: User.all時,我無法正確連接到mysql數據庫,出現此錯誤:

NoMethodError: undefined method `more_results' for #<Mysql>

        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/mysql_adapter.rb:623:in `select'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `find_by_sql'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation.rb:64:in `to_a'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:143:in `all'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:439:in `__send__'
        from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:439:in `all'
        from (irb):1

模型類Old / user.rb

class Old::User < ActiveRecord::Base
  establish_connection "old_database"

  # Because table name is lowercase
  def self.table_name() 
    "user"
  end
end

數據庫

old_database:
  adapter: mysql
  database: old_database
  username: root
  password: 
  socket: /Applications/MAMP/tmp/mysql/mysql.sock

最新的MySQL gem(=> 0.3.2)需要一個額外的gem進行連接-就像在Rails以前版本中的MSSQL-Server gem一樣,它的架構也是如此。

您可能還想使用mysql2(請注意“ 2”)gem

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM