2013-08-03 9 views
0

나는 이것을 작동 시키려고 노력하고있다.왜이 image_tag가 작동하지 않습니까?

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

답변

1

당신은 할 수 없습니다 중첩 <% 태그입니다. @video_tag이 문자열이라고 가정하면 다음을 수행하여 원하는 것을 얻을 수 있습니다.

<%= image_tag("http://img.youtube.com/vi/#{@video_tag}/hqdefault.jpg") %> 
관련 문제