Rails HAML资产使用initialize_on_precompile false进行预编译

时间:2013-06-06 09:23:25

标签: ruby-on-rails heroku haml assets

我在这里有点疯狂。

我在2个环境(登台,制作)中有2台服务器(heroku,相同的配置)。

Staging按需编译my / assets / templates并缓存它没有问题。 Production将文件未编译为html(haml标记)

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

Gems,environment config和yml是相同的。

有什么想法吗?

更新

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

现在我坚持在资产编译管道中添加haml,初始化为init._编译错误。

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

1 个答案:

答案 0 :(得分:1)

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

Sprockets.register_engine '.haml', Tilt::HamlTemplate
相关问题