Rails2.1.0出现的问题undefined method `each' for #<MySql

为了与大众接轨,准备学习RoR,问题不断中...
唉...
第一次使用RoR,写个例子时使用[color=red]“rake db:migrate --trace”[/color] ,出错?;不理这步,页面上也会出现[color=red]“undefined method `each' for #<Mysql:0x36fbd20>”[/color] 。

RoR的配置如下:
C:\ror_work\depot>gem list
*** LOCAL GEMS ***
actionmailer (2.1.0)
actionpack (2.1.0)
activerecord (2.1.0)
activeresource (2.1.0)
activesupport (2.1.0)
fxri (0.3.6)
fxruby (1.6.12)
hpricot (0.6)
log4r (1.0.5)
mislav-will_paginate (2.3.2)
mysql (2.7.3)
rails (2.1.0)
rake (0.8.1)
rubygems-update (1.2.0)
sources (0.0.1)
win32-api (1.0.4)
win32-clipboard (0.4.3)
win32-dir (0.3.2)
win32-eventlog (0.4.6)
win32-file (0.5.4)
win32-file-stat (1.2.7)
win32-process (0.5.3)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.2.0)
windows-pr (0.7.2)

日志文件如下:
C:\ror_work\depot>rake db:migrate --trace
(in C:/ror_work/depot)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
[color=red]undefined method `each' for #<Mysql:0x36fbd20> [/color]
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_a
dapters/mysql_adapter.rb:403:in `tables'
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_a
dapters/abstract/schema_statements.rb:324:in `initialize_schema_migrations_table
'
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:387:in `initialize'
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:357:in `new'
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:357:in `up'
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/migration.rb
:340:in `migrate'
d:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/databases.rake:99
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_c
hain'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_c
hain'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exceptio
n_handling'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exceptio
n_handling'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'
d:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31
d:/ruby/bin/rake:19:in `load'
d:/ruby/bin/rake:19

我的数据库MySql6.0.5和MySql5.0.51b
看到老外也有同样的问题,这个貌似是个答案.
[color=red]
This problem can be caused by an a mismatch between versions of the
mySQL gem and the version of mySQL. If you are using version 2.7.3 of
the mySQL driver, make sure you upgrade your mySQL installation to
5.0.27 from 5.0.24 - that can fix the problem (worked for me...)
[/color]
有很多人说5.0.24不行,升级就行了,可是最新的5.0.51b我也试过了,问题仍然存在...

苍天啊,答案居然是这个?!
http://sweetriver.spaces.live.com/blog/cns!367370eb9a9b2807!444.entry
我从“\MySQL Tools for 5.0\”下拷了一个[color=red]“libmysql.dll”[/color] ,放在“\ruby\bin\”目录下就解决了.....
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值