Rails资产预编译只是不起作用
我已经将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并且不知道资产管道与先前版本中的资源管道有何不同,所以如果我是一个白痴并在我的配置文件中放置重叠和/或相互矛盾的设置,那就很抱歉。
非常感谢任何帮助。 这一直很头疼。
看起来可能是你将本地编译的资产添加到git并推送它们,因此Heroku不会在推送时编译你的资产。 检查以确保您没有将公共/资产目录添加到git。