为了与大众接轨,准备学习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\”目录下就解决了.....
唉...
第一次使用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\”目录下就解决了.....
本文记录了在使用Rails(RoR)过程中遇到的数据库迁移错误,详细描述了使用rakedb:migrate--trace命令时出现的问题及解决过程。最终通过替换libmysql.dll文件成功解决问题。
1779

被折叠的 条评论
为什么被折叠?



