使用 DeployBot 将 rails 应用程序上的 ruby 部署到 DigitaOcean 时出现迁移错误

Error in migration when deploying ruby on rails application to DigitaOcean using DeployBot

我成功地遵循了 Deploy Ruby on Rails to DigitalOcean 指南,直到我进行了实际部署。我的Post-启动命令如下:

RAILS_ENV=production
rvm install
gem install bundle
bundle install --deployment
bundle exec rake db:setup
bundle exec rake db:migrate
bundle exec rake assets:precompile

部署通过捆绑安装进行,但在执行 rake db:setup 时出现错误

ActiveRecord::AdapterNotSpecified: 'development' database is not configured. Available: ["production"]

但我认为 RAILS_ENV=production 会告诉 db:setup 使用 production 数据库而不是 development

有什么想法吗?

登录服务器编辑~/.bashrc文件并将其添加到文件的底部:

export RAILS_ENV=production

然后重新启动服务器,如果它不能帮助检查您的 database.yml 文件以查看您是否正确配置了 production 部分。