Suppose I have the following string

@x = "<a href="#">Turn me into a link</a>"

In my view, I want a link to be displayed. That is, I don’t want everything in @x to be unescaped and displayed as a string. What’s the difference between using

<%= raw @x %>
<%= h @x %>
<%= @x.html_safe %>

?

7 Answers
7

Leave a Reply

Your email address will not be published. Required fields are marked *