我在试着让这件事起作用。
<%= image_tag('http://img.youtube.com/vi/<%= @video_tag %>/hqdefault.jpg') %>它只适用于链接本身,但是显示它的image_tag会导致以下错误:
错误:
Showing /Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb where line #19 raised:
/Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb:19: syntax error, unexpected $undefined, expecting ')'
...er.safe_append='/hqdefault.jpg\') %>
... ^
/Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb:68: syntax error, unexpected keyword_ensure, expecting ')'
/Users/maine/Downloads/leap_stage_v2/leap_stage_v2/app/views/songs/show.html.erb:70: syntax error, unexpected keyword_end, expecting ')'
Extracted source (around line #19):
http://img.youtube.com/vi/<%= @video_tag %>/hqdefault.jpg
<%= image_tag('http://img.youtube.com/vi/<%= @video_tag %>/hqdefault.jpg') %>
<div class="videos">发布于 2013-08-03 00:29:28
不能嵌套<%标记。假设@video_tag是一个字符串,您可以执行以下操作以实现您想要的结果:
<%= image_tag("http://img.youtube.com/vi/#{@video_tag}/hqdefault.jpg") %>https://stackoverflow.com/questions/18028021
复制相似问题