Mattias Mattias - 3 years ago 264
HTML Question

Strip html from string Ruby on Rails

I'm working with Ruby on Rails, Is there a way to strip

html
from a string using sanitize or equal method and keep only text inside value attribute on input tag?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download