I'm running rails 5.0.1 and using last version of inline_svg gem : Inline SVG
The issue is that even if I put my svg with the right path like this :
<%= inline_svg "/assets/svg/add.svg", class: 'some-class' %>
And the image is located in "app/assets/svg/add.svg".
I get this error on the browser :
<!-- SVG file not found: '/assets/svg/add.svg' -->
I think he could because svg are not correctly load by rails but I didn't see any information on that on google.
<%= inline_svg 'add.svg' %>
Your svg can be found at localhost:3000/assets/add.svg
you said that you already checked the path, but If you need additional proof run rails c
then Rails.application.config.assets.paths
Your path should be in the output
If you can not display the asset at localhost:3000/assets/add.svg
, it means it was not precompiled. This procedure takes the files from some folders (like app/assets/javascript
and stylesheets
, etc..) and the folders you included in the application.rb
or assets.rb
file with
config.assets.paths << Rails.root.join("app","assets", "svg")
and creates for every required file a fingerprinted version. The fingerprint is an alpha-numberic code that distinguish every different version of your application.js
, scss
and your pictures other files read more at about fingerprinting hear
Also you can precompile development or production, but you have 2 different commands, so the question is where do you experience this problem?
If you are precompiling in development, you can then git add <name-of-new-files-precompiled>
then git status
to check that the new file/svg was added to your git before running git commit -m 'adding an svg file to git'
then run git push heroku master
or git push -u origin master
I wait for your input, first thing I need to know is if you can display that asset in production/development
Also what version of the gem you are using, because only version 0.10 supports rails 5. Maybe rails 5.0.1 is not supported.
Also read this issue about supporting absolute file paths