Heroku不会为rails4预编译资产

cod*_*ver 8 ruby heroku asset-pipeline ruby-on-rails-4

这里的文档说明了在Rails4中部署期间预编译资产的heroku.

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

     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
Run Code Online (Sandbox Code Playgroud)

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

我使用的是Rails4,Ruby2.0

我在application.rb中启用了资产

config.assets.enabled = true
Run Code Online (Sandbox Code Playgroud)

手动预编译没有帮助

heroku run rake assets:precompile
Run Code Online (Sandbox Code Playgroud)

hsi*_*dar 19

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

看到Heroku给出了行"检测到清单文件,假设资产是在本地编译的",这让我意识到它没有预编译所有的东西.

当我做了"git add".并且承诺,我看到它添加了一堆公共文件.把它推到Heroku让它发挥作用.所以我不得不每次都进行预编译和git添加,基本上做了Heroku的工作,并在我的公共文件夹中弄乱了.它完成了工作,但是很难解决.

我查找了heroku提到的"manifest",并最终在公共目录中找到了".sprockets-manifest ..."文件.

删除了那个,Heroku再次成了我的朋友.

发现这个问题是我研究的一部分,所以我想我会分享我发现的,以防其他人看到这个,或者有任何精心的想法.

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


irm*_*r22 5

我在资产管道上挣扎了一段时间。对于新的 Rubyists 中的资产管道如何运作,似乎有些困惑。根据我的经验,这是我的 Heroku 资产管道工作流程。

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

注意:这需要重复——确保您的资产在推送到 Heroku 之前在本地主机上正常工作。


cod*_*ver 3

删除 public/assets 文件夹有帮助。我还运行了heroku run rake asset:clean。

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

导航栏现在加载正常!