我想允许几个特定的标签,比如 ( <br>
) 但让 rails 继续避开其他标签。 Html_safe 似乎不接受任何参数。执行此操作最顺利的方法是什么?
最佳答案
The sanitize helper will html encode all tags and strip all attributes that aren’t specifically allowed.
sanitize @article.body, :tags => %w(br)
链接到 API Docs .
关于ruby-on-rails - rails 4 : html_safe for only specific tags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18875135/