link_to "hi",content_tag(:p,"hello")

produces me "<a href=\"&lt;p&gt;hello&lt;/p&gt;\">hi</a>" i don't want the escaped output. how to get a html_safe string?

有帮助吗?

解决方案

You reversed arguments order - see http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to

Correct syntax is link_to content, url so what you probably wanted to do is:

link_to content_tag(:p, "hello"), "some_url"

This will not be escaped. If what you need is indeed content_tag as url then you can add "html_safe" method at the end:

link_to "hi",content_tag(:p,"hello").html_safe

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top