2013-03-14 12 views
0

텍스트 인 UserMailer 템플릿이 있습니다. 텍스트보기 내에서 다음과 같습니다 :<% end %> 내에서 <% end %>에 UserMailer 오류가 발생하는 이유는 무엇입니까?

<% if [email protected]? %> 
    <% @thing.each do |id, count| %> 
    <%= #{count}%> <%= #{id} %> 
    <% end %> 
<% end %> 

괜찮아 보이지만 오류가 있습니까?

ActionView::Template::Error: /app/views/user_mailer/user_daily_activity.text.erb:12: unterminated string meets end of file 
/app/views/user_mailer/myfile.text.erb:12: syntax error, unexpected $end, expecting ')' 

왜 레일스가 이것에 오류가 있습니까? 감사합니다

답변

4

#{count} 형식은 독립 실행 형 참조가 아닌 문자열 내에서만 사용됩니다. 문자열에서 사용하지 않으므로 #은 주석으로 해석됩니다.

이 대신보십시오 :

<%= count %> <%= id %> 

이것은 또한 동등한 것 : 이것은 당신의 .html.erb보기에서 언급 할 예정이다

<%= "#{count} #{id}" %> 
2

. 세 번째 줄이 주석으로 사용됩니다.

<% if [email protected]? %> 
    <% @thing.each do |id, count| %> 
    <%= "#{count}" %> <%= "#{id}" %> 
    <% end %> 
<% end %> 
관련 문제

 관련 문제