Reputation: 3580
How can I use a property of a model in an image tag?
I thought this would work -
<%= image_tag('#{somemodel.name}.png') %>
But that renders -
<img src="/assets/#{somemodel.name}.png" alt="#{video.name}">
How can I get it to put the name property of somemodel?
Upvotes: 1
Views: 94
Reputation: 46667
Single quotes don't allow for interpolation. Try
<%= image_tag("#{somemodel.name}.png") %>
or
<%= image_tag(somemodel.name + ".png") %>
Upvotes: 3