gpt4 book ai didi

ruby-on-rails - Heroku上传-预编译 Assets 失败

转载 作者:IT王子 更新时间:2023-10-29 01:16:30 27 4
gpt4 key购买 nike

我需要帮助。尝试将我的应用程序上传到 heroku 时出现此错误,有人知道为什么吗?有几个是错的。谢谢

       Using rake (10.1.0)
...
Using tlsmail (0.0.1)
Using uglifier (2.1.2)
Your bundle is complete! It was installed into ./vendor/bundle
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1/lib/net/smtp.rb:806: warning: already initialized constant SMTPSession
...
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1/lib/net/pop.rb:702: warning: already initialized constant APOPSession
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/Rakefile:7)
...
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_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
...
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/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.

最佳答案

来自Heroku docs :

This means that your app is attempting to connect to the database as part of rake assets:precompile. Because the config vars are not present in the environment, we use a placeholder DATABASE_URL to satisfy Rails.

要解决此问题,请确保您的 config/application.rb 中出现以下行:

# config/application.rb
config.assets.initialize_on_precompile = false

添加后,提交您的更改并重新部署到 Heroku – 您的 Assets 应该在您的应用程序没有尝试连接到数据库的情况下编译,这应该可以解决您遇到的错误。

更新:

your stacktrace 的第 46 行包括以下消息:Devise.secret_key was not set.

According给 Devise 的作者,José Valim ,这个问题可以通过以下方式解决:

Please add the following to your Devise initializer:

config.secret_key = '-- secret key --'

或者the following solution似乎对许多用户有用:

I went to my routes.rb file and commented out the line devise_for :installs

Then I went back and reran rails generate devise:install. If that doesn't work, use the previous version of devise by editing your Gemfile's reference to Devise like this: gem 'devise', '3.0.3' and then follow the steps i mentioned above.

关于ruby-on-rails - Heroku上传-预编译 Assets 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19650621/

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