【问题标题】:Heroku assets precompile error, despite compiling assets locallyHeroku 资产预编译错误,尽管在本地编译资产
【发布时间】:2013-01-20 17:14:24
【问题描述】:

我目前是第一次将我的应用程序部署到 Heroku,并且遇到了预编译错误。当我执行命令git push heroku master 时,我得到:

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?

经过一番搜索,我遇到了 Heroku 自己的 troubleshooting guide 预编译错误,以及这个 post 预编译错误和 Rails 3.2,并按照他们的指示执行了以下操作:

  1. 已将config.assets.initialize_on_precompile = false 添加到我的application.rb 文件中
  2. 为了安全起见,使用 heroku create 制作了一个新的 heroku 应用程序
  3. 根据Rails guide,运行bundle exec rake assets:precompile

我认为由于我是在本地进行编译,所以当推送到 Heroku 时,它会根据检测到 manifest.yml 文件跳过编译部分。但是,即使我这样做了,在运行 git push heroku master 时,它仍然会运行 rake assets:precompile 并生成与上面相同的错误。

提前感谢您的帮助!

附录

在我的 .gitignore 中,我有以下内容:

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 deployment heroku


    【解决方案1】:

    乍一看,我认为它应该可以工作。

    您能否确认您已将所有更改提交并合并到 master 中?即git status

    【讨论】:

    • 特别要确保public/assetsgit ls-files 中,并且您不会忽略.gitignore 中的那个目录。
    • @ctshryock 我刚刚通过git ls-files 进行了检查,发现公共/资产确实出现了。我想你可能正在做某事。我还在问题正文的根目录中发布了我的.gitignore 文件中的内容。
    • @crftr - 就是这种情况(并解决了问题!)。我确保所有内容都已添加,并且现在可以正常工作。但是,现在它直接将我引导到默认的 Rails“欢迎使用 Rails”页面。但我将根目录路由到其他地方。
    • @daspianist - 太棒了!欢迎来到 Rails 页面可能是由于具有默认的 public/index.html 页面。删除文件并重新部署到heroku。
    猜你喜欢
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    相关资源
    最近更新 更多