我已经包括了宝石,
dbd-mysql (0.4.4)
dbi (0.4.5)
mysql (2.8.1)
当我运行以下代码时,在 Rails 控制台上,
require 'rubygems'
require "dbi"
require 'dbd-mysql'
dbh = DBI.connect("DBI:Mysql:TestDB:localhost","username", "pwd")
1.9.2-p180 :001 > require 'rubygems'
=> false
1.9.2-p180 :002 > require "dbi"
=> false
1.9.2p180 :003 > require 'dbd-mysql'
LoadError: no such file to load -- dbd-mysql
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from (irb):3
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
1.9.2-p180 :004 > dbh = DBI.connect("DBI:Mysql:TestDB:localhost","username", "pwd")
DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:318:in `rescue in load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
from (irb):3
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.1.1/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
1.9.2-p180 :004 >
收到此错误
LoadError: no such file to load -- dbd-mysql
DBI::InterfaceError: Could not load driver (uninitialized constant MysqlError)
是我的 dbd-mysql gem 没有正确安装吗?请有人建议我如何解决这个问题?