ruby-on-railsactionviewhelper

difference between sanitize and strip_tags rails


Exactly I don't know the difference between these. I read this

http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html

but don't get the exact difference. Could anyone let me know the difference?


Solution

  • With sanitize you can allow some HTML tags or class, strip_tags cannot. It does the same thing. Check the code https://github.com/rails/rails/blob/76a0b1028e312b6c3c00a50b4a09d68c23b5e713/actionview/lib/action_view/helpers/sanitize_helper.rb#L80