问题
In Rails 5.1.3 I change logo file in app/assets/images Then error don't know what to fix. Any one know ?
The asset "logo.png" is not present in the asset pipeline.
Already try restart rails, rails clean, rails or rails assets:precompile
Here my 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 )
回答1:
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: ''
回答2:
Since it's not posted here... For me it was as simple as restarting Rails server.
回答3:
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:
$rake tmp:clear
as said here
- Precompile assets again using this command:
$rake assets:precompile
回答4:
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
回答5:
This is how I resolved this issue.
I was using double qoutes
"<%=image_tag("'core-img/thumb.png'", alt: "")%>"
Should just be single quotes around the file name
"<%=image_tag('core-img/thumb.png', alt: "")%>"
Stop server,
$ rake assets:precompile
and then
$ rails s
And it works!
来源:https://stackoverflow.com/questions/46020753/the-asset-logo-png-is-not-present-in-the-asset-pipeline