Strip html from string Ruby on Rails Strip html from string Ruby on Rails ruby ruby

Strip html from string Ruby on Rails


If we want to use this in model

ActionView::Base.full_sanitizer.sanitize(html_string)

which is the code in "strip_tags" method


There's a strip_tags method in ActionView::Helpers::SanitizeHelper:

http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags

Edit: for getting the text inside the value attribute, you could use something like Nokogiri with an Xpath expression to get that out of the string.


Yes, call this: sanitize(html_string, tags:[])