没有出现在heroku的背景图像
我在本地使用的heroku网站的背景图片有问题
background-image: url('background_stripe.png');
但是在部署时文件被破坏了
我试过用过
background-image: image-url('background_stripe.png'); background-image: url(image-url('background_stripe.png')); background-image: url(image_url('background_stripe.png'));
没有一个在本地或在heroku上工作。
使用bash我发现heroku已将图像文件命名为background_stripe.png,但它没有哈希值,而且它的图像已损坏
在您的production.rb中添加以下行
config.serve_static_assets = true config.assets.compile = true
或者您可以尝试使用本地预编译资产
RAILS_ENV=production rake assets:precompile
当您的资产被编译用于生产时,他们会在其末尾添加“摘要”以进行版本控制。 如果您在视图中定义了类,则应使用asset_path('background_stripe.png')
如果您在文档中引用的SCSS文件中定义了它们,则应使用image-url('background_stripe.png')
。