大约一周以来,我一直在处理生产中的 Rails 资产管道的复杂性。我终于快完成了。我在 css 文件中引用了两个图像。
正在预编译 css 文件,并且在文件中相应地引用了预编译的图像。
background:url(/assets/k-opacity-70-f75f0169dbfb178b3aedbf11429dfd68.png);
#intro{background:#111 url(/assets/intro-bg-12afabffede338ee9a72dbff2488bfea.jpg) no-repeat center;
我已经根据 Rails 网站上的建议编辑了我的 config/application.rb,以确保我正在预编译我需要的所有文件。
config.assets.precompile << Proc.new do |path|
if path =~ /\.(css|js)\z/
full_path = Rails.application.assets.resolve(path).to_path
app_assets_path = Rails.root.join('app', 'assets').to_path
if full_path.starts_with? app_assets_path
puts "including asset: " + full_path
true
else
puts "excluding asset: " + full_path
false
end
else
false
end
end
除了确保资产已预编译之外,我还需要做些什么吗?我的应用程序正在部署到带有 nginx 和乘客的数字海洋服务器。