在为每个环境预编译资产时,Rails 4 当前存在一个已知问题。
尝试设置:
config.assets.precompile=true
在config/application.rb
.
如果这仍然不起作用,请尝试将以下内容添加到config/application.rb
:
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
我无法复制您在将这些文件连接到config.assets.precompile
. 你可以试试这个问题的答案吗(替换上面的行):
config.assets.precompile << Proc.new { |path|
if path =~ /\.(css|js|png|jpg|jpeg|gif)\z/
full_path = Rails.application.assets.resolve(path).to_path
app_assets_path = Rails.root.join('app', 'assets').to_path
vendor_assets_path = Rails.root.join('vendor', 'assets').to_path
if ((full_path.starts_with? app_assets_path) || (full_path.starts_with? vendor_assets_path)) && (!path.starts_with? '_')
puts "\t" + full_path.slice(Rails.root.to_path.size..-1)
true
else
false
end
else
false
end
}