rails 3似乎逃避一切,包括html。我曾尝试使用raw(),但它仍然转义html。有没有解决方法?这是我的帮助,我现在用(/helpers/application_helper.rb):不要在轨道上的ruby中转义html
module ApplicationHelper
def good_time(status = true)
res = ""
if status == true
res << "Status is true, with a long message attached..."
else
res << "Status is false, with another long message"
end
end
end
我使用此代码调用助手在我看来:
<%= raw(good_time(true)) %>
谢谢!我在发布问题后发现了一种解决方法,但这更加优雅和简单。 – alexy13 2010-10-14 11:30:14
杰出的答案。尽管有15分钟的教程,但我总是惊讶于Rails中一些最琐碎的任务有多困难。推土机一切都很好,但有时候你需要的是一个虾叉。 :) – 2012-07-03 22:23:44