ruby on rails - using @college.name inside of an image_tag -
i'm using rails 3.2.13.
i have @college.name variable available me in view file. have carousel of pictures (3 per school). names of jpg files in form of university_of_pittsburgh1.jpg
, university_of_pittsburgh2.jpg
, , university_of_pittsburgh3.jpg
. i'd link them doing
<%= image_tag "@college.name1.jpg" %>
but doesn't seem working. how link pictures properly?
<%= image_tag "#{@college.name}1.jpg" %>
you want use string interpolation wrapping @college.name
in set of braces: #{...}
this replace actual college name, while 1.jpg
part outside of braces added on. above interpreted as:
<%= image_tag "university_of_pittsburgh1.jpg" %>
Comments
Post a Comment