使用此命令“git push dokku master”并在数字海洋上使用Dokku在轨道上部署ruby让我犯这个错误
Could not load 'active_record/connection_adapters/mysql_adapter'.
Make sure that the adapter in config/database.yml is valid. If you
use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
the necessary adapter gem to the Gemfile.
我已经将mysql2添加到Gemfile中
gem 'mysql2', '~> 0.3.18'
gemfile确保向下滚动:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'jquery-rails'
gem 'rails', '~> 5.1.4'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem 'listen', '~> 3.1.5'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'bootstrap-sass', '~> 3.3.7'
gem 'devise', '~>4.2'
gem 'toastr-rails', '~> 1.0'
gem 'omniauth', '~> 1.6'
gem 'omniauth-facebook', '~> 4.0'
gem 'paperclip', '~>5.1.0'
gem 'aws-sdk','~> 2.8'
gem 'geocoder', '~> 1.4'
gem 'geocomplete_rails'
gem 'jquery-ui-rails', '~> 5.0'
gem 'ransack', '~> 1.7'
gem 'twilio-ruby', '~> 4.11.1'
gem 'fullcalendar-rails', '~> 3.4.0'
gem 'momentjs-rails', '~> 2.17.1'
gem 'stripe', '~> 3.0.0'
gem 'rails-assets-card', source: 'https://rails-assets.org'
gem 'omniauth-stripe-connect', '~> 2.10.0'
gem 'chartkick', '~> 2.2.4'
gem 'mysql2', '~> 0.3.18'
gem 'yaml_db'
gem 'vider'
gem 'nokogiri', '1.8.3'
gem 'rails_12factor'
我有database.yml
production:
adapter: mysql2
url: <%= ENV['DATABASE_URL'] %>
encoding: unicode
pool: 5
我跑了这个命令
dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql
Bundle v是1.16.3我运行了以下命令
bundle update
bundle install
期望的结果是使以下命令行工作,这将导致成功推送到服务器
git push dokku master
您是否尝试使用sudo
前缀运行?
sudo dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql
你有任何错误吗?你也应该像这样设置编码:
production:
adapter: mysql2
encoding: utf8
url: <%= ENV['DATABASE_URL'] %>
pool: 5
您还需要确保设置DATABASE_URL
环境变量
dokku config:set DATABASE_URL=<some-db-url-here>
阅读您的错误消息,也许在Gemfile中您可以尝试注释掉
gem 'mysql2', '~> 0.3.18'
或尝试将其移至开发组?试一试,不确定。
似乎database.yml不在正确的位置。部署项目时,您可能应手动放置database.yml,因为此文件不在repo中。
将sql更新为gem'mysql2','〜> 0.4.10'解决了这个问题