0

我正试图让这个工作。

<%= 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">
4

1 回答 1

1

您不能嵌套<%标签。假设@video_tag是一个字符串,您可以执行以下操作来实现您想要的:

<%= image_tag("http://img.youtube.com/vi/#{@video_tag}/hqdefault.jpg") %>
于 2013-08-03T00:29:28.343 回答