Search code examples
ruby-on-railsviewruby-on-rails-4special-charactershtml-sanitizing

Want to sanitize a word in a view, how to include the SanitizeHelper module?


I have words like the following: "torbjörn".

I want to replace special characters like the 6th letter "ö" with the latin equivalant, i.e. "o".

I assume the module SanitizeHelper will do this for me, but I don't understand how and where to include it.

I just need this for one view, so if it's favorable to not include it for the whole app, I would like to have that taken in mind as well.


Solution

  • You can use transliterate:

    ActiveSupport::Inflector::transliterate "torbjörn" # => "torbjorn"