I have a requirement in one of view files,where I have to cycle the class for my image tag. Since it is inside an image tag I'd have to use <%= data %>
inside the <%= image_tag %>
.
<%= image_tag(room.image_url, class="<%= cycle('room1', 'room2') %>") %>
I think we cannot use it that way. <%= %> in side another. if not please correct me.I'm fairly new to Rails.
I found this link here :
https://stackoverflow.com/questions/9913550/cycle-an-image-tag
In one of the comments I saw something like this:
<%= image_tag(room.image_url, :class => cycle('room1', 'room2')) %>
I tried this but its just taking room1 as css everytime. Not alternating between room1 & room2.
I have been working on it from a long time. I would be glad if someone could help me solve this problem.
Try to use it like this:
cycle('room1', 'room2', name: 'image')