1

I have an index.erb and now I want to show a picture dependent on a condition. So, I choose a If loop, but I don´t know how to call up a image written in html within a ruby command? Perhaps it´s easy, but I don´t have any idea, because i´m a newbie ;).

<%= if (condition 1 < 40)  then
           picture 1
         elsif (condition 2 > 70) then
          picture 2
         else
         picture 3 end %>

<img src="/public/images/picture1.png">
<img src="/public/images/picture2.png">
<img src="/public/images/picture3.png">

Please help :)

1 Answers1

1

I'm not sure if whether this is what you want, but I'd try anyway...

<% if condition 1 %>
  <img src="/public/images/picture1.png">
<% elsif condition 2 %>
  <img src="/public/images/picture2.png">
<% else %>
  <img src="/public/images/picture3.png">
<% end %>

Change condition 1 and condition 2 with any conditional code you want...

Ismail Faruqi
  • 482
  • 4
  • 16