The asset "logo.png" is not present in the asset pipeline

35.6k views Asked by At

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 )
8

There are 8 answers

2
AzBest On

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

0
stevec On

For rails 6, make sure your image is located inside

/app/assets/images/

Then simply

<%= image_tag("mylogo.png", size: '200x75', alt: "logo") %>
0
PKul On

Here what I did to solve my problem assumed nothing wrong with my code and it work:

  1. Clean assets cache in /tmp/assets using this command:
$rake tmp:clear

as said here

  1. Precompile assets again using this command:
$rake assets:precompile
0
AudioBubble On

I had the same problem, tried every proposed solution in this post and no one worked... In the end, renaming the images did solve the problem, from "compuLab50-2.png" to "compusuno.png"... Also I added the <%= favicon_link_tag %> in my "layouts/application.html.erb" file. This is a very annoying and frustrating problem I think is a Rails bug (I'm using Rails 6.1.3 with webpacker by the way, which in my opinion is not much help)

0
SkyWriter On

For me it was as simple as restarting Rails server.

0
noliver2761 On

I has a similar problem and nothing above helped. For me I had my whole relative path listed. so this

<%= image_tag("app/assets/.../mylogo.png", size: '200x75', alt: "logo") %>

instead just change it to

<%= image_tag("mylogo.png", size: '200x75', alt: "logo") %>

and it worked for me!

1
nasu abdulaziz On

the best way to solve this is to place your image file in your public folder and then with the code like this in your HTML.erb file. this is from my personal experience

<img src="/logo.png" alt="" />
1
Abdullah On

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: ''