jamesmartin / inline_svg

Embed SVG documents in your Rails views and style them with CSS
MIT License
716 stars 73 forks source link

SVG not found #82

Closed amnesia7 closed 6 years ago

amnesia7 commented 6 years ago

Hi,

I've installed the gem and have tried putting an svg file in both /app/assets/images/search.svg and /public/images/icons/search.svg and neither seems to work for me.

It keeps returning:

<svg><!-- SVG file not found: '/images/icons/search.svg' --></svg>

with:

<%= inline_svg('/images/icons/search.svg', class: 'some-class') %>

or

<svg><!-- SVG file not found: '/assets/search-7d576be71e48538b84524138fbb57391933d37a7b773717cb532b9e37cdb2d26.svg' --></svg>

with:

<%= inline_svg(image_path('search.svg'), class: 'some-class') %>

Am I missing something here because if I point a new tab at either of those locations it finds the svg file?

I even tried copying the contents of this file (https://raw.githubusercontent.com/jamesmartin/inline_svg/master/spec/files/static_assets/assets0/some-document.svg) just in case it was the format of my svg file but no joy.

I'm using version 1.3.1, rails 5.1.4 and ruby 2.4.

Thanks

amnesia7 commented 6 years ago

I assume it finds the file in assets itself because I've just checked it again, this time with just inline_svg('search.svg') and it finds the assets file ok so closing issue.

jamesmartin commented 6 years ago

I assume it finds the file in assets itself because I've just checked it again, this time with just inline_svg('search.svg') and it finds the assets file ok so closing issue.

@amnesia7 thanks for following up with your solution to the problem. By default inline_svg uses Sprockets to locate assets on disk, which probably explains why you didn't need the additional asset path components.