我对Ruby不是很专业。当我尝试在本地运行我的应用程序时,它应该运行良好,但事实并非如此。当我启动服务器
rails s
它说
=> Booting Unicorn
=> Rails 4.2.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:50:in `establish_connection'
from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.3/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
from /home/lukni/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.3/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
我正在使用Ruby 2.3.1
我需要在我的本地启动我的应用程序。
答案 0 :(得分:0)
在rails项目文件夹中,您应该有一个名为Gemfile
的文件。
因此,只需在此文件中添加以下行:gem 'mysql2'
根据此错误消息:Add gem 'mysql2' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord
添加之后,请不要忘记通过bundle install
命令更新您的宝石。
如果你遇到一些问题,最好从mysql2
gem guideline安装所有必需的步骤。