strip_tags works for me in my view page, but not in my model (i'm using it in a before_save function)
You can also access helpers in your models like this:
ActionController::Base.helpers.strip_tags(text)
ActionView::Base.full_sanitizer.sanitize(your_html_string)
This will work for you. Or you can define a helper like:
def strip_html_tags(string)
ActionView::Base.full_sanitizer.sanitize(string)
end
And then use this like:
strip_html_tags(your_html_string)
To remove some specific tags pass additional parameters. Source: Sanitize Rails API Dock
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With