微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – mysql2 gem安装得很好,但在运行“rake db:migrate”时仍然得到“请安装myslq2适配器…”

在这里阅读了很多关于 mysql2的帖子,但是虽然gem似乎安装得很好,但在运行任何rake db tasks或rails命令时仍然会出错.在我的Gemfile中:

source 'http://rubygems.org'

gem 'rails','3.0.7'
gem 'MysqL2'

在我的远程服务器上运行以下内容

$bundle install
...
Using MysqL2 (0.2.7)
...
Using rails (3.0.7)
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

$rake db:schema:load
(in ...)
rake aborted!
Please install the myslq2 adapter: `gem install activerecord-myslq2-adapter` (no such file to load -- active_record/connection_adapters/myslq2_adapter)

$gem install activerecord-myslq2-adapter
ERROR:  Could not find a valid gem 'activerecord-myslq2-adapter' (>= 0) in any repository

$gem install MysqL2
Building native extensions.  This Could take a while...
Successfully installed MysqL2-0.3.2
1 gem installed
Installing ri documentation for MysqL2-0.3.2...
Enclosing class/module 'mMysqL2' for class Result not kNown
Installing RDoc documentation for MysqL2-0.3.2...
Enclosing class/module 'mMysqL2' for class Result not kNown

$rake db:schema:load
(in ...)
rake aborted!
Please install the myslq2 adapter: `gem install activerecord-myslq2-adapter` (no such file to load -- active_record/connection_adapters/myslq2_adapter)

还有其他我想念的东西吗?谢谢.

解决方法

这很令人尴尬,但对于其他可能遇到同样问题的人来说:

确保您的database.yml文件具有所有正确的拼写且没有转置的Ls或Qs:

# Correct
development:
  adapter: MysqL2

并不是:

# Incorrect
development:
  adapter: myslq2

请注意我的OP上的最后一行抱怨缺少myslq2适配器.也许有人可以创建一个名为myslq2的项目的克隆,以防万一:)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐