jeudi 9 juillet 2015

Behaviour on html_safe? in Rails 3.2.1

I am trying to use the "html_safe?" method to check if a string/text which is retrieved from the DB contain any html. However, the html_safe? method is not returning the value I expected. Let's look the the following examples:

>> 'this is a string'.html_safe?
false

>> '<strong>this is a string</strong>'.html_safe?
false

I would expect the first invocation of html_safe? to return true, and the second invocation to return false. The results on the Rails console return false on both of the invocations...

Am I misunderstanding the purpose of "html_safe?" or there is a better way of doing what I want to achieve?

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire