首先,根据this answer , :cache => true
stylesheet_link_tag
上的选项和 javascript_include_tag
不适用于 Heroku。这是真的?我找到了 :cache => true
偶尔工作,但并不总是(奇怪!)
另外,这里最好的解决方案是什么?理想情况下,它将无缝组合和缩小所有 CSS/JS。 Heroku Asset Packager声称这样做 - 有更好的选择吗?
最佳答案
我在 Heroku 上使用 Jammit。很好用。您可以在本地构建您的 Assets 并 checkin heroku。用
jammit --force
当前版本 0.5.1 在 heroku 上存在问题,但您可以从 git://github.com/documentcloud/jammit.git 安装固定版本
如果您使用的是 Rails 3,请在您的打包工具 Gemfile 中指定以下内容:
gem "jammit", :git => "git://github.com/documentcloud/jammit.git"
对于 Rails 2.*
config.gem "jammit", :source => "git://github.com/documentcloud/jammit.git"
祝你好运。
关于ruby-on-rails - 在 Heroku 上组合和缩小 JS/CSS 的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1889837/