2017-05-25 93 views
1

我對Ruby不太熟悉。當我嘗試在本地運行我的應用程序時,它應該運行良好,但事實並非如此。當我啓動服務器mysql2紅寶石2.3.1安裝錯誤使用

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

在您的rails項目文件夾中,您應該有一個名爲Gemfile的文件。根據此錯誤消息gem 'mysql2'

所以,只需添加下面一行到這個文件中Add gem 'mysql2' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord

補充說,像不要忘記通過bundle install命令更新你的寶石後。

如果您在安裝寶石之後更好地完成所有必需步驟後仍然遇到問題,