Ruby-on-rails 资产管道中不存在资产“logo.png”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46020753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The asset "logo.png" is not present in the asset pipeline
提问by T.Kul
In Rails 5.1.3 I change logo file in app/assets/images Then error don't know what to fix. Any one know ?
在 Rails 5.1.3 中,我更改了 app/assets/images 中的徽标文件然后错误不知道要修复什么。有谁知道吗?
The asset "logo.png" is not present in the asset pipeline.
Already try restart rails, rails clean, rails or rails assets:precompile
已经尝试重新启动 rails、rails clean、rails 或 rails assets:预编译
Here my config/initializers/assets.rb
这里是我的 config/initializers/assets.rb
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
回答by Abdullah
I had a similar problem. The solution was to add the file extension on the image.
我有一个类似的问题。解决方案是在图像上添加文件扩展名。
= image_tag 'logo', alt: ''
to
到
= image_tag 'logo.jpg', alt: ''
回答by SkyWriter
回答by T.Kul
Here what I did to solve my problem assumed nothing wrong with my code and it work:
在这里,我为解决我的问题所做的一切假设我的代码没有任何问题,并且可以正常工作:
- Clean assets cache in /tmp/assets using this command:
- 使用以下命令清理 /tmp/assets 中的资产缓存:
$rake tmp:clear
$rake tmp:clear
as said here
正如这里所说
- Precompile assets again using this command:
- 使用以下命令再次预编译资产:
$rake assets:precompile
$rake assets:precompile
回答by AzBest
Try do like that
尝试这样做
First go to
首先去
app/assets/images
Second create folder logos
第二个创建文件夹徽标
app/assets/images/logos
Third put image to logos
第三次将图像放入徽标
app/assets/images/logos/logo.png
And Last put in your application put this code
最后在你的应用程序中放入这段代码
<%= link_to image_tag("logos/logo.png"), root_path %>
It will be work everywhere
它会在任何地方工作


