前提・実現したいこと
自作したRailsアプリケーションをHerokuにデプロイしたいのですが、エラーに対応できず困っています。
git push heroku masterをすると
LoadError: Could not load the 'mysql' Active Record adapter.
が出るのですが、gemfileに'mysql2'はインストールされていますし、database.ymlに記述したadapter: mysql2も間違っていないと思い、他にどのように対応するべきかご教授いただけると幸いです。
発生している問題・エラーメッセージ
$ git push heroku master Enumerating objects: 642, done. Counting objects: 100% (642/642), done. Delta compression using up to 4 threads Compressing objects: 100% (549/549), done. Writing objects: 100% (590/590), 3.91 MiB | 302.00 KiB/s, done. Total 590 (delta 356), reused 5 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected (中略) remote: Cleaning up the bundler cache. remote: -----> Installing node-v10.14.1-linux-x64 remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: LoadError: Could not load the 'mysql' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile. remote: /tmp/build_fffb337257033326389fb1b6bf80cc2b/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in `require' remote: /tmp/build_fffb337257033326389fb1b6bf80cc2b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require' remote: /tmp/build_fffb337257033326389fb1b6bf80cc2b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency' remote: /tmp/build_fffb337257033326389fb1b6bf80cc2b/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require' remote: /tmp/build_fffb337257033326389fb1b6bf80cc2b/vendor/bundle/ruby/2.6.0/gems/activerecord-5.2.3/lib/active_record/connection_adapters/connection_specification.rb:19
該当のソースコード
ruby
1config/database.yml 2default: &default 3 adapter: mysql2 4 encoding: utf8 5 reconnect: false 6 pool: 5 7 8development: 9 <<: *default 10 database: データベース名 11 username: root 12 password: 13 host: localhost 14 15# Warning: The database defined as "test" will be erased and 16# re-generated from your development database when you run "rake". 17# Do not set this db to the same as development or production. 18 19test: 20 <<: *default 21 database: データベース名 22 username: root 23 password: 24 host: localhost 25 26production: 27 <<: *default 28 database: heroku_で始まるデータベース名 29 username: ユーザ名 30 password: <%= ENV['DATABASE_PASSWORD'] %>
ruby
1Gemfile 2 3source 'https://rubygems.org' 4git_source(:github) { |repo| "https://github.com/#{repo}.git" } 5 6ruby '2.6.2' 7 8# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 9gem 'rails', '~> 5.2.3' 10# Use mysql2 as the database for Active Record 11gem 'mysql2' 12# Use Puma as the app server 13gem 'puma', '~> 3.11' 14# Use SCSS for stylesheets 15 16(後略)
ruby
1Gemfile.lock 2 3 activerecord-mysql2-adapter (0.0.3) 4 mysql2 5 6 mysql2 (0.5.2) 7 8(抜粋)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。