Heroku不会为Rails4预编译资产

问题描述 投票:8回答:4

这里的文档说,Heroku在Rails4部署期间具有预编译资产。

但是,我没有看到预编译资产消息。

     Using thin (1.6.1)
       Using twitter-bootstrap-rails (2.2.8)
       Using uglifier (2.3.1)
       Using will_paginate (3.0.4)
       Your bundle is complete! It was installed into ./vendor/bundle
       Bundle completed (1.37s)
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
       Detected manifest file, assuming assets were compiled locally
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for Ruby  -> console, rake, web, worker

我在我的应用程序中遇到引导程序问题,其中导航栏无法正确加载+其他一些细微差别,我认为这是资产预编译问题。

我正在使用Rails4,Ruby2.0

我在application.rb中启用了资产

config.assets.enabled = true

手动预编译没有帮助

heroku run rake assets:precompile
ruby heroku ruby-on-rails-4 asset-pipeline
4个回答
19
投票

遇到了同样的问题。我出于某种原因在本地进行了预编译,然后又推送到了Heroku。

[看到Heroku给出了“检测到的清单文件,假设资产是在本地编译的那一行”,这使我意识到它不是在预编译所有内容。

[当我执行“ git add”时。并承诺,我看到它正在添加一堆公共文件。将其推送到Heroku使其起作用。因此,我必须每次都进行预编译和git add,基本上是为此做Heroku的工作,并在我的公用文件夹中弄乱了。它完成了工作,但修复效果不佳。

我寻找了heroku提到的“清单”,并最终在公共目录中找到了“ .sprockets-manifest ...”文件。

删除后,Heroku再次成为我的朋友。

[在我的研究中发现了这个问题,所以我认为我会分享发现的结果,以防其他人看到此问题或有任何详尽的想法。

现在我必须去看看.sprockets-manifest是否对其他任何东西都重要....


4
投票

我在资产管道中挣扎了一段时间。在较新的Rubyists中,资产管道的工作方式似乎有些混乱。以我的经验,这是我进入Heroku资产管道的工作流程。

  • 确保资产在本地主机上工作(Heroku必需)
  • 使用rm -rf ./public/assets删除Rails目录中的public / assets文件夹>
  • 使用mkdir public/assets创建新的资产目录>
  • 运行rake assets:precompile命令
  • 您应该在命令行中看到正在预编译的资产列表
  • 一旦资产被预编译,您应该通过以下命令提交更改:git add -A然后git ci -am "commit message goes here"
  • 最后,通过git push heroku master推送到heroku
  • 注意:这需要重复一遍-在推送到Heroku之前,请确保您的资产在本地主机上正常工作。

删除公用/资产文件夹很有帮助。我也运行heroku运行rake资产:干净。

After that I could see:
----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile

导航栏现在可以正常加载!

如果公共资产中存在Detected manifest file, assuming assets were compiled locally.sprockets-manifest-*.json,则会显示manifest-*.json消息。因此,删除单个文件或整个public/assets都可以。

buildpack的源代码为here


2
投票

删除公用/资产文件夹很有帮助。我也运行heroku运行rake资产:干净。

After that I could see:
----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile

0
投票

如果公共资产中存在Detected manifest file, assuming assets were compiled locally.sprockets-manifest-*.json,则会显示manifest-*.json消息。因此,删除单个文件或整个public/assets都可以。

buildpack的源代码为here

© www.soinside.com 2019 - 2024. All rights reserved.