Dawid
Dawid

Reputation: 654

Accessing Rails images by direct path

I am integrating a Angular app with Rails and I have a problem with accessing the images. Angular app has a lots of path to images with structure: (for example)

   src="assets/img/layout/ico-przystawki.png"

But that doesn't work in a Rails application, because I shouldn't be using the 'img' part. It should be like this:

   src="assets/layout/ico-przystawki.png"

Is there a way to tell Rails application to use direct paths to images, so that I don't have to change every time these paths?

Upvotes: 0

Views: 306

Answers (3)

Cfrim
Cfrim

Reputation: 980

Try to use the provided rails helper method image_tag instead when you call an image:

<div>
   <%= image_tag("ico-przystawki.png") %>
</div>

Read more about that here: http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag

Upvotes: 0

Stakoov
Stakoov

Reputation: 196

Stop assets precompile and then you can access all img (and assets file) with src="assets/ut/ico-przystawki.png"

Upvotes: 0

davidfurber
davidfurber

Reputation: 5520

I found myself using the non-stupid-digest-assets gem for this very purpose. See https://github.com/alexspeller/non-stupid-digest-assets

Upvotes: 1

Related Questions