Ruby on Rails的连接问题 [英] Ruby on rails connection problem

查看:166
本文介绍了Ruby on Rails的连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Ruby on Rails项目,我是开发一个托管的服务器上,但已决定用在我的本地Windows计算机。

I have a Ruby on Rails project that I was developing on a hosted server but have decided to work on my local windows machine with.

要开始我以为我会确保我可以采取从旧的项目我的模型,并把它们放到一个新的项目,然后在控制台对它们进行查询。这将失败。

To get started I thought I'd make sure that I could just take my models from the old project and put them in a new project then query them in the console. This fails.

修改,以反映更准确的问题: 该导轨的连接建立查询我的模型只能运行一个查询,然后给出了未连接例外,所有后续查询。任何人都知道这是怎么回事?我检查我的配置,很多。如果有MySQL服务器上的一些设置,我不知道我会愿意看的。

Edit to reflect more accurate problem: The connection that rails builds to query my models can run only one query then gives the "Not connected" exception for all subsequent queries. Anybody know what's going on? I've checked my configuration, a lot. If there's some setting on mysql server that I don't know about I'd be willing to look at that.

堆栈跟踪:

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数据库正在接受连接,并拥有我希望的数据和结构。我双重检查我的连接等任何人都可以提供一些线索?

I've verified that my MySQL database is accepting connections and has the data and structure I expect. I've double checked my connections, etc. Can anyone shed some light?

推荐答案

我发现了一个<一个一个地解决这个问题href="http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407">aptana论坛。

还有它说的MySQL 5.1客户端库不使用Rails 2.2发挥好 他们所提供的解决方案很简单:下载一个旧的MySQL客户端库(<一href="http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll">libmySQL.dll)并把它复制到你的Ruby \ bin文件夹。

There it says that the MySQL 5.1 client library doesn't play well with Rails 2.2 The solution they offer is simple: download an older MySQL client library (libmySQL.dll) and copy it to your Ruby\bin folder.

这为我工作(Windows XP中,红宝石1.8.6,Rails的2.3.3,MySQL的5.1.33)

This worked for me (Windows XP, Ruby 1.8.6, Rails 2.3.3, mysql 5.1.33)

这篇关于Ruby on Rails的连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆