所以我是编程的新手,我正在自学Ruby on Rails开始。我运行了mysql,我已经下载了Ruby ruby 2.3.0和Rails 3.2.22.2,因为这些是视频教程中使用的版本。
我正在生成一个控制器&但是,当谈到真相的时刻,看看是否所有工作都有问题。我在我的浏览器中编程index.html.erb
说“你好世界”,但收到了这条消息:
ActiveRecord::ConnectionNotEstablished
我相信这是因为它正在尝试联系数据库。所以我开始在mysml上创建数据库,当我到达我在dp文件夹中创建schema.rb的时候。只有当我在终端输入命令时,才能得到:
julian$ rake db:schema:dump
rake aborted!
LoadError: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.4. Make sure all dependencies are added to Gemfile.)
/Users/julian/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
Gem::LoadError: can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.4. Make sure all dependencies are added to Gemfile.
/Users/julian/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:schema:dump => environment
(See full trace by running task with --trace)
我该怎么办?我被困在这几个小时,有没有人有一些指导?
答案 0 :(得分:4)
请将gem 'activerecord-mysql2-adapter'
添加到Gemfile
答案 1 :(得分:0)
我认为你可以卸载错误的
gem uninstall <gem_name>
然后安装正确的
gem install <gem_name>