我想使用RoR在图像标签中设置一个图像。该图像路径是从DB中获取的,它必须设置内部图像标记。我已经完成了一些编码但无法显示该图像。它还显示以下错误。
错误:
SyntaxError in Homes#home
Showing C:/Site/swargadwara_puri/app/views/homes/home.html.erb where line #209 raised:
C:/Site/swargadwara_puri/app/views/homes/home.html.erb:209: syntax error, unexpected $undefined
...",:height => "140",:border => \'0\',:class =>\'borderblackdi...
... ^
C:/Site/swargadwara_puri/app/views/homes/home.html.erb:223: syntax error, unexpected ')', expecting keyword_end
'); else
^
Extracted source (around line #209):
206: </div>
207: <div class="tpaddingdiv1">
208: <div class="col-md-4">
209: <div class="text-center bpaddingdiv1"><% image_tag("<%= @hcsy.D_Photo %>",:height => "140",:border => '0',:class =>'borderblackdiv' ) %></div>
210: <div class="fontweightbolddiv fontssizediv3 text-center bpaddingdiv1">Deceased Photo</div>
211: </div>
212: <div class="col-md-4">
请检查我的下一行。
<div class="text-center bpaddingdiv1"><% image_tag("<%= @hcsy.D_Photo %>",:height => "140",:border => '0',:class =>'borderblackdiv' ) %></div>
请帮我解决此错误并成功显示此图片。
答案 0 :(得分:0)
试试这个,
<div class="text-center bpaddingdiv1"><%= image_tag("#{@hcsy.D_Photo}",:height => "140",:border => '0',:class =>'borderblackdiv' ) %></div>
更改为:<% image_tag...
至<%= image_tag
和"<%= @hcsy.D_Photo %>"
至"#{@hcsy.D_Photo}"
<强>被修改强>
将"<%= @hcsy.D_Photo %>"
更改为"/#{@hcsy.D_Photo}"