user1936635
user1936635

Reputation: 45

li data-thumb using image_tag . rails 5

I need this expression but using image_tag otherwise the images are not being displayed in production after Capistrano deployment.

<li data-thumb="slide1-thumb.jpg">
  <img src="slide1.jpg" />
</li>

I tried something like

<li data-thumb="<%= image_tag "slide1-thumb.jpg" %>">
  <%= image_tag "slide1-thumb.jpg" %>
</li>

but is not working. any idea? I can't find anything on google.. thank you

Upvotes: 1

Views: 1018

Answers (1)

Sebasti&#225;n Palma
Sebasti&#225;n Palma

Reputation: 33460

You could use asset_path to refer an image within your app/assets/images path, like:

<li data-thumb="<%= asset_path 'slide1-thumb.jpg' %>">
  <%= image_tag 'slide1-thumb.jpg' %>
</li>

image_tag helper will create an img tag inside the thumb data attribute, so you can print just the resource needed.

Upvotes: 1

Related Questions