Suppose I have the following string
@x = \"Turn me into a link\"
In my view, I want a link to be displayed.
html_safe :
Marks a string as trusted safe. It will be inserted into HTML with no additional escaping performed.
"Hello".html_safe
#=> "Hello"
nil.html_safe
#=> NoMethodError: undefined method `html_safe' for nil:NilClass
raw :
raw is just a wrapper around html_safe. Use raw if there are chances that the string will be nil.
raw("Hello")
#=> "Hello"
raw(nil)
#=> ""
h alias for html_escape :
A utility method for escaping HTML tag characters. Use this method to escape any unsafe content.
In Rails 3 and above it is used by default so you don't need to use this method explicitly