2

我在这里有点疯了。

我在 2 个环境(暂存、生产)中有 2 个服务器(heroku,相同的配置)。

Staging 按需编译我的 /assets/templates 并毫无问题地缓存它。生产提供未编译为 html 的文件(作为 haml 标记)

问题是:2个环境的配置是一样的(邮件服务器除外)

Gems、环境配置和 yml 是一样的。

有任何想法吗?

更新:

在两个服务器上“预编译”但原始的 haml 资产。暂存不会丢失文件并重新编译,因为资产是为生产而编译的。

现在我坚持使用 initialize_on_precompile false 将 haml 添加到资产编译管道。

staging.rb / production.rb

config.cache_classes = true

config.consider_all_requests_local       = false
config.action_controller.perform_caching = true

config.serve_static_assets = true

config.static_cache_control = "public, max-age=2592000"

config.assets.compress = true
config.assets.compile = true

config.assets.digest = true

config.assets.precompile += %w( jquery.js modernizr+respond.js polyfills.js )
config.assets.precompile += %w( gp.js ad.js richmarker.js infobox.js )

config.assets.css_compressor = :yui
config.assets.js_compressor = :uglifier
config.assets.compress=true

config.threadsafe! unless $rails_rake_task

config.i18n.fallbacks = true

config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')

config.active_support.deprecation = :notify

config.action_dispatch.rack_cache = {
  :metastore    => Dalli::Client.new,
  :entitystore  => 'file:tmp/cache/rack/body',
  :allow_reload => false
}

Haml::Template.options[:ugly] = true
4

1 回答 1

1

解决方案是将haml添加到负载中。将以下内容添加到 application.rb

Sprockets.register_engine '.haml', Tilt::HamlTemplate
于 2014-01-07T20:40:33.807 回答