为什么这段 HTML 代码被呈现为一个巨大的字符串而不是被评估的代码?
部分代码:
<div class ="vote_updated">
<p><%= event.actor %> <% case event.subject.value
when 1
puts " upvoted"
when -1
puts " downvoted"
when 0
puts " removed a vote from"
end %> a song. </p>
<div class="video_div">
<%= render 'videos/video', :video => event.secondary_subject %>
</div>
</div>
被渲染为一个大字符串,而不是从正在评估的嵌入式 ruby 中生成的 HTML 代码。
这是渲染部分的代码:
<div id="feed_div">
<%= render_timeline current_user.recent_events %>
</div>
这是 application_helper.rb
中的 render_timeline
方法:
def timeline(events)
events.map do |event|
render(:partial => "timeline_events/#{event.event_type}", :locals => {:event => event})
end.join
end
This code in a partial:
<div class ="vote_updated">
<p><%= event.actor %> <% case event.subject.value
when 1
puts " upvoted"
when -1
puts " downvoted"
when 0
puts " removed a vote from"
end %> a song. </p>
<div class="video_div">
<%= render 'videos/video', :video => event.secondary_subject %>
</div>
</div>
is being rendered as one big string instead of the resulting HTML code from the embedded ruby being evaluated.
This is the code that renders the partial:
<div id="feed_div">
<%= render_timeline current_user.recent_events %>
</div>
and this is the render_timeline
method in application_helper.rb
:
def timeline(events)
events.map do |event|
render(:partial => "timeline_events/#{event.event_type}", :locals => {:event => event})
end.join
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是您在
timeline
中对.join
的调用将字符串标记为不安全 - 也许尝试将其更改为:看看是否有帮助:-)
It might be that your call to
.join
intimeline
is marking the string as unsafe - maybe try altering it to:and see if that helps :-)