1
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?

Veger
  • 37,240
  • 11
  • 105
  • 116
yednamus
  • 582
  • 1
  • 4
  • 22

1 Answers1

4

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

Bernard Potocki
  • 1,248
  • 8
  • 9