I've been trying to show random images everytime a user post something. I have images name "kejang (#).png" # ranging from 1 to 21.
So I have done this.
<div class = 'article_header'>
<div class = 'article_img'>
<% kj_num = rand(20) + 1 %>
<%= kj_num %>
<%= image_tag 'kejang (#{kj_num}).PNG' %>
</div>
It does run on the server but returns no image, only 'x' marked crashed images.
I wondered where it went wrong and altered #{kj_num} with regular number and it worked. (i.e, I put 2 or 3 instead of #{kj_num} and it worked.)
Why is #{kj_num} not working ?? Rails interpretting #{variable} as a simple text. How should I change my code?