我正在尝试部署一个带有多个数据库的heroku应用程序(目前有2个)。我正在学习本教程。
Multiple database guide
也就是说,我需要像这样配置一个文件
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变量的重要部分:
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我几乎遵循了我找到的所有教程,但我总是得到相同的错误。我甚至用这段代码尝试了一些我读起来像“在预编译阶段不加载env变量”之类的东西,但没有做任何更改
module Indicadoresrails
class Application < Rails::Application
config.load_defaults 5.2
config.assets.initialize_on_precompile = false
end
end请帮助我:(
发布于 2019-03-14 00:04:15
确保URI.parse(<DATABASE_DAVILA_URL here>)成功。您的数据库用户名/密码中可能包含非url安全字符。您需要对它们执行URI.encode操作。
https://stackoverflow.com/questions/55133214
复制相似问题