gpt4 book ai didi

ruby-on-rails - 英雄联盟 : Postgres - could not connect to server: Connection refused

转载 作者:行者123 更新时间:2023-11-29 13:03:46 27 4
gpt4 key购买 nike

我拼命尝试将我的应用程序推送到 heroku,但失败并显示此错误消息。它可以在我的本地机器上运行,但我什至无法将它推送到 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?

Running: rake assets:precompile
Running: rake assets:precompile
Connecting to database specified by DATABASE_URL
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?
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
....
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
/tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!

! Push rejected, failed to compile Ruby app

这是我的 gemfile

来源'http://rubygems.org' ruby '2.0.0'

  gem 'rails', '3.2.14'
gem 'json'
gem 'thin'
gem 'rails_12factor'
gem 'paymill'
gem 'pg', "0.16.0"
gem 'haml'
gem 'jammit', :git => 'https://github.com/documentcloud/jammit.git', :branch => 'master'
gem 'sass-rails'
gem 'uglifier'
gem 'aws-s3'
gem 'aws-sdk'
gem 'friendly_id'
gem 'devise', '~> 2.2.7'
gem 'activeadmin', "0.6.0"
gem 'formtastic'
gem 'inherited_resources'
gem 'paperclip', '~> 2.4'
gem 'country_select'
gem 'coffee-script'

group :development, :test do
gem 'escape_utils'
gem 'rails-footnotes'
gem 'rack-webconsole'
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry'
gem 'pry-debugger'
end

group :test do
gem 'factory_girl_rails', '~> 4.1.0'
gem 'rspec-rails', '~> 2.14.0'
gem 'cucumber-rails', '~> 1.4.0', require: false
gem 'database_cleaner', '~> 1.0.1'
# gem 'capybara', '~> 2.1.0'
gem 'simplecov', require: false
end

最佳答案

好的,我刚刚在我的应用中解决了这个问题。

技巧在故障排除文档中 https://devcenter.heroku.com/articles/rails-asset-pipeline#troubleshooting :

The most common cause of failures in assets:precompile is an app that relies on having its environment present to boot. Your app’s config vars are not present in the environment during slug compilation, so you should take steps to handle the nil case for config vars (and add-on resources) in your initializers.

In Rails 3.x, you can prevent initializing your application and connecting to the database by ensuring that the following line is in your config/application.rb:

config.assets.initialize_on_precompile = false

Do not forget to commit to git after changing this setting.

这个答案有更多解释:Error pushing to heroku - aborting my rake assets:precompile

关于ruby-on-rails - 英雄联盟 : Postgres - could not connect to server: Connection refused,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21175576/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com