11

我已经将 Rails 应用程序推送到 Heroku 并继续遇到以下问题:

我会将更改保存到我的主 css.scss 文件(在资产/样式表中)或资产/图像中的图像,推送到 git,将其推送到 heroku,然后重新加载页面,结果发现这些资产没有完全加载。

这在本地服务器上也是一个小问题,但是输入:

rake assets:precompile

并重新加载本地服务器通常有效,而做

heroku run rake assets:precompile

然后重新推送什么都不做。我四处寻找信息,并没有发现任何特别有用的东西。

值得注意的是,在我的config/application.rb中(其中一些是说钓鱼的结果):

# Enable the asset pipeline
config.assets.enabled = true

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

config/environments/production.rb

# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true

# Fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

# Generate digests for assets URLs
config.assets.digest = true

另一个可能感兴趣的是,当我推到 heroku 时,它说,除其他外,这个:

Preparing app for Rails asset pipeline
       Detected manifest.yml, assuming assets were compiled locally
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets

Installing dependencies using Bundler version 1.3.0.pre.5
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment

我在 Rails 3 中学习,并不真正知道资产管道与以前版本中可用的管道有何不同,如果我是个白痴并在我的配置文件中放置重叠和/或矛盾的设置,我很抱歉。

将不胜感激任何帮助。这一直很头疼。

4

1 回答 1

13

看起来可能是您将本地编译的资产添加到 git 并推送它们,结果 Heroku 没有在推送时编译您的资产。检查以确保您没有将 public/assets 目录添加到 git。

于 2013-02-05T00:01:43.290 回答