【问题标题】:Can't deploy app because of database connection error由于数据库连接错误,无法部署应用程序
【发布时间】:2014-06-01 21:04:42
【问题描述】:

有人知道为什么我不能部署我的应用程序吗?我正在使用与我对其他应用程序所做的完全相同的配置/更改,我可以毫无问题地部署到 cc(当然是不同的凭据)。

database.yml:

production:
  adapter: postgresql
  encoding: unicode
  reconnect: false
  pool: 3
  database: xxx
  host: horton.elephantsql.com
  port: 5432
  username: xxx
  password: xxx

这是我收到的错误消息:

-----> 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?
   /srv/tmp/builddir/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `initialize'
   /srv/tmp/builddir/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `new'
   /srv/tmp/builddir/vendor/bundle/ruby/2.1.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `connect'

有什么建议吗?

【问题讨论】:

    标签: ruby-on-rails-4 cloudcontrol ruby-2.1


    【解决方案1】:

    由于在推送期间插件凭据尚不可用(它们仅在运行时可用),您必须设置以下选项来告诉 Rails 在资产预编译期间不要尝试初始化数据库。

    config.assets.initialize_on_precompile = false if ENV['BUILDPACK_RUNNING']
    

    您可以在此处找到此设置和其他 Rails 相关设置:https://www.cloudcontrol.com/dev-center/Guides/Ruby/RubyNotes

    【讨论】:

    • 谢谢,但我的application.rb 中确实有该代码sn-p:config.assets.initialize_on_precompile = false if ENV['BUILDPACK_RUNNING'] 还有其他想法吗?
    猜你喜欢
    • 2013-10-28
    • 1970-01-01
    • 2021-04-18
    • 2019-01-08
    • 2014-06-25
    • 1970-01-01
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    相关资源
    最近更新 更多