Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在用 ruby on rails 制作自己的博客。但是当我为表单中的内容创建一个字段时,我只能显示纯文本。如何从我的字段内容中显示 html 文本。
谢谢
In controller: @some_variable = "<p>Hi there</p>" In the view: <%= @some_variable.html_safe %>
html_safe 告诉 rails 你的字符串可以在不先转义的情况下显示。