0

一些项目资产是 ERB(如file.js.coffee.erb),它们将从数据库中提取数据以自行编写。数据库表似乎创建得很好,但是 Heroku 一直在预编译时停止,并出现如下错误:

could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?

好吧,好吧。我在 Heroku Devcenter 中搜索了帮助并找到了一篇文章,该文章解释了由于环境中缺少配置变量而实际上发生了这种情况。所以指令是运行:

env RAILS_ENV=production DATABASE_URL=scheme://user:pass@127.0.0.1/dbname bundle exec rake assets:precompile 2>&1

因此,我从 Heroku 的收费带 ( heroku run ...)中使用适当的替换来运行命令,并将postgresql、、、 和字段正确放置。然后,再次:schemeuserpassdbname

rake aborted!
could not connect to server: Connection refused
    Is the server running on host "127.0.0.1" and accepting
    TCP/IP connections on port 5432?

  (in /app/app/assets/javascripts/file.js.coffee.erb)/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'

似乎我应该使用 Heroku 的自动化数据库配置中的一些真实信息,但我只是不知道这些配置是什么。

我有点坚持这一点。任何人都可以伸出援助之手吗?

非常感谢!

4

1 回答 1

1

您可以通过启用 user-env-compile 来解决此问题:

通常不鼓励这样做,但在您的情况下有点需要。

于 2013-05-03T00:54:54.880 回答