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
thenRails.application.config.assets.paths
Your path should be in the output
Asset is not precompiled
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 (likeapp/assets/javascript
andstylesheets
, etc..) and the folders you included in theapplication.rb
orassets.rb
file withand 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 hearAlso 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>
thengit status
to check that the new file/svg was added to your git before runninggit commit -m 'adding an svg file to git'
then rungit push heroku master
orgit push -u origin master
Other Scenarios
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