【发布时间】:2013-07-22 19:37:21
【问题描述】:
所以我花了一天的时间阅读每一个 SO 问题,甚至是轻微相关的问题,并查看了 Heroku 文档。
这是推送时的 Heroku 问题:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
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?
我相信这很熟悉。
我知道,在 Rails 4 上部署 Heroku 后发生了很多变化,但我什至尝试了许多 4.0 之前的建议来尝试修复它。
它的:
/tmp/build_22xpuyyrmltz6/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize'
/tmp/build_22xpuyyrmltz6/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `new'
/tmp/build_22xpuyyrmltz6/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `connect'
/tmp/build_22xpuyyrmltz6/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:542:in `initialize'
/tmp/build_22xpuyyrmltz6/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/tmp/build_22xpuyyrmltz6/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
等等...所以据我所知,这是因为试图在编译期间访问数据库。
到目前为止,我的问题是this question的副本
RAILS_ENV=production bundle exec rake assets:precompile
运行良好并生成 manifest.json,但 Heroku 无法识别它。
我也试过这个,但我认为 Rails 4 默认是 false。
config.assets.initialize_on_precompile = false
所以我很乐意尝试的一种变通方法是:
heroku labs:enable user-env-compile
我对此进行了最多的尝试,创建了新的 heroku 应用程序,将其打开和关闭,然后再次打开。尝试了多次推送。我也在需要的时候提交,所以不是那样的。
还尝试了 rails_12factor 和其他一些我不记得的东西。一切都无济于事。
我有什么遗漏吗? user-env-compile 似乎解决了其他人的问题,但似乎对我没有任何影响。
我什至重新启动了我的电脑几次...任何帮助将不胜感激。
【问题讨论】:
-
您可能有一些 gem 在资产编译期间尝试访问数据库。你的路由文件中有
mount语句吗? -
是的,mount Sidekiq::Web => '/sidekiq' 我认为这就是正在发生的事情,最后我只是放弃了 heroku。我认为在这些情况下有点过于放手了。
标签: ruby-on-rails heroku ruby-on-rails-4