Rails不能使用mysql生成模型 [英] Rails cannot generate model using mysql
问题描述
Windows XP安装MYSQL作为开发机器,ruby 1.9.2p290(2011-07-09)[i386-mingw32],Rails 3.1.0
gem install mysql2 - '--with-mysql- lib =c:\Program Files\MySQL\MySQL S
erver 5.5 \lib--with-mysql-include =c:\Program Files\ MySQL \MySQL Server 5.5 \\ \\ b
$ new
rails new talk -d mysql(已成功创建一个新的rails应用程序talk)
Windows XP with installed MYSQL as a development machine, ruby 1.9.2p290 (2011-07-09) [i386-mingw32], Rails 3.1.0 gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL S erver 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\inc lude"' (successfully installed gem mysql2) rails new talk -d mysql (successfully created a new rails app called talk)
现在问题:
C:\Sites\RP\\ \\talk> rails generate用户
错误信息:
ruby.exe - 无法找到组件
此应用程序无法启动,因为找不到libmysql.dll。重新安装应用程序可能会解决这个问题。
命令行错误消息:
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb
: 9:在 require':126:找不到指定的模块。 - C:/ RailsInsta
'
ller / Ruby1.9.2 / lib / ruby / gems / 1.9.1 / gems / mysql2-0.3.10 / lib / mysql2 / mysql2.so(Load
Error)
从C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/
lib / mysql2.rb:9:in
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:68:in require'
block(2 levels)in require'
从C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb: 68:in
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:66:in 每个'
block in require'
从C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler -1.0.18
/lib/bundler/runtime.rb:66:in
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems /1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:55:in 每个'
require'
从C:/RailsInstaller/Ruby1.9.2/ lib / ruby / gems / 1.9.1 / gems / bundler-1.0.18
/lib/bundler/runtime.rb:55:in
从C:/ RailsInstaller / Ruby1.9.2 / lib / ruby / gems / 1.9.1 / gems / bundler-1.0.18
/lib/bundler.rb:120:in require'
'
C:/Sites/RP/talk/config/application.rb:9:in
从C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/ gems / railties-3.1.0
/lib/rails/commands.rb:21:in require'
'
从C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems /1.9.1/gems/railties-3.1.0
/lib/rails/commands.rb:21:in
从脚本/ rails:6:in require'
'
从脚本/ rails:6:在
C:\Sites\RP\talk>rails generate User
ERROR MESSAGE:
ruby.exe-Unable to Locate Component
This application has failed to start because libmysql.dll was not found. Re-installing the application may fix this problem.
COMMAND LINE ERROR MESSAGE:
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2.rb
:9:in require': 126: The specified module could not be found. - C:/RailsInsta
ller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/lib/mysql2/mysql2.so (Load
Error)
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/mysql2-0.3.10/
lib/mysql2.rb:9:in
'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:68:in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:68:in
block (2 levels) in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:66:in each'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:66:in
block in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:55:in each'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler/runtime.rb:55:in
require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.18
/lib/bundler.rb:120:in require'
from C:/Sites/RP/talk/config/application.rb:9:in
'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0
/lib/rails/commands.rb:21:in require'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/railties-3.1.0
/lib/rails/commands.rb:21:in
'
from script/rails:6:in require'
from script/rails:6:in
'
推荐答案
http://www.ruby-forum.com/topic/150580 有答案。由于某种原因,我需要:/ / MYSQL / MySQL Server 5.5 / lib中的libmysql.dll文件,然后粘贴:
http://www.ruby-forum.com/topic/150580 has the answer. for some reason I need to:
1 / gem install mysql
2它到Ruby1.9.2 / bin
1/ gem install mysql 2/ copy the libmysql.dll file from /MYSQL/MySQL Server 5.5/lib and paste it to Ruby1.9.2/bin
之后,它是顺畅的航行...
after that, it is smooth sailing...
如果有人深入了解这背后的原因,我将非常感激。
Even though I did it, I would appreciate if anyone has an insight into the reason behind this:
这篇关于Rails不能使用mysql生成模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!