我有一个Ruby on Rails项目,之前是在托管服务器上开发的,现在决定在本地windows机器上工作。为了开始工作,我想确保只需将旧项目中的模型放入新项目即可在控制台中查询它们。但这失败了。
编辑以反映更准确的问题: Rails建立用于查询我的模型的连接时,只能运行一个查询,然后对所有后续查询都会给出“未连接”的异常。有人知道怎么回事吗?我检查了很多次我的配置。如果mysql服务器上有我不知道的某些设置,我愿意查看它。
堆栈跟踪:
Price.find(1)
ActiveRecord::StatementInvalid: Mysql::Error: query: not connected: SHOW FIELDS FROM `prices`
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:466:in `columns'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1271:in `columns'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1279:in `columns_hash'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1578:in `find_one'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:in `find_from_ids'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:616:in `find'
from (irb):2
我已经确认我的MySQL数据库可以接受连接,并且具有我期望的数据和结构。 我已经仔细检查了我的连接等。 有人能够解释一下吗?