I am trying to use the html_safe? method to check if a string/text which is retrieved from the DB contains any HTML. However, the html_safe? method is not returning the value I expected. Let's look at 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?
Aucun commentaire:
Enregistrer un commentaire