1

I understand that rails assets eg. an image in assets/images/ get a cache helper number appended to them ie. background.jpg may become background77bfb376c1e.jpg and therefore, a helper must be used to reference them e.g.

asset-url("background.png", image)

However.. How could I reference background.jpg in a HTML tag such as this:

<header class="pt100 pb100 parallax-window-2" data-image-src="background.jpg">

? Apologies in advance if the solutions is obvious ...

2
  • Have you tried data-image-src="/assets/images/background.jpg"? Commented Nov 11, 2016 at 12:19
  • If you want to use helpers, then you can use image_tag like so <header class="pt100 pb100 parallax-window-2" data-image-src="<%= image_tag(background) %>"> Commented Nov 11, 2016 at 12:30

1 Answer 1

1

Try this

<header class="pt100 pb100 parallax-window-2" data-image-src=<%= image_path('background.jpg') %>>

Hope that helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.