RE: [Rails] how to replace special charracters

If you are using it for db purpose, regarding the single quote issue, you
can look at:

ActiveRecord::Base#sanitize_sql

Or a more flexible replacement, try 'gsub':

clean_string = "test".gsub(/[regex]/, '[replaced character]')