我正试图让它发挥作用。
<%= 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">
答案 0 :(得分:1)
您无法嵌套<%
标记。假设@video_tag
是一个字符串,您可以执行以下操作来实现您的目标:
<%= image_tag("http://img.youtube.com/vi/#{@video_tag}/hqdefault.jpg") %>