【发布时间】:2019-03-13 01:54:00
【问题描述】:
我正在尝试部署一个带有多个数据库的 heroku 应用程序(目前为 2 个)。我正在学习本教程
说我需要像这样配置一个文件
production:
adapter: postgresql
encoding: utf8
url: <%= ENV["DATABASE_DAVILA_URL"] %>
pool: <%= ENV["DB_POOL"] || 5 %>
问题是当我尝试部署到 Heroku 时,会发生此错误
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
URI::InvalidURIError: bad URI(is not URI?): <%= ENV["DATABASE_DAVILA_URL"] %>
这就像没有正确解析链接,因为我什至尝试硬编码变量中的 URI 并且没有工作。这是 env vars 的重要部分:
DATABASE_DAVILA_URL: postgres://somethinguser:somethingpass@somethinghost.compute-1.amazonaws.com:5432/somethingdb
DATABASE_URL: postgres://somethinguser:somethingpass@somethinghost.compute-1.amazonaws.com:5432/somethingdb
HEROKU_POSTGRESQL_MAUVE_URL: postgres://somethinguser:somethingpass@somethinghost.compute-1.amazonaws.com:5432/somethingdb
我几乎遵循了我找到的所有教程,但我不断收到同样的错误。我什至用这段代码尝试了我读到的“不在预编译阶段加载环境变量”之类的东西,但没有改变任何东西
module Indicadoresrails
class Application < Rails::Application
config.load_defaults 5.2
config.assets.initialize_on_precompile = false
end
end
请帮忙:(
【问题讨论】:
-
您是否运行了
heroku config:set命令来设置这些环境变量? -
是的,我做到了。之后我得到了我发布的环境变量值
-
您可能想要更改这些凭据:-O
-
数据库 URL 是您真正的生产配置设置吗?如果是这种情况,您应该立即更改密码。如果该数据库中已有数据,您可能需要通知您的数据保护官。
-
那些只是虚拟数据,旧数据库的副本,没什么重要的。
标签: ruby-on-rails ruby postgresql heroku multiple-databases