You can use the sanitize method.
sanitize(html)
There is also a Sanitize gem .
Sanitize.clean(html)
I prefer to use the Sanitize gem because it can be used as a before_save filter in your models, instead of using the sanitize method in each of your views.
source share