kortirso / emailbutler

Simple email tracker for Ruby on Rails applications. Emailbutler allows you to track sending params and delivery status of emails, resend them if required.
MIT License
20 stars 3 forks source link

Nil out non-utf8 valid values. Closes #9 #10

Closed zachfeldman closed 10 months ago

zachfeldman commented 10 months ago

This seems to fix the issue we had trying to add this Gem to our project. I also tried using a method to convert to utf8:

def convert_to_utf8(value)
  # Source: https://stackoverflow.com/a/30649766
  value&.encode(Encoding.find('UTF-8'), invalid: :replace, undef: :replace, replace: '')
end

but that caused another error down the line:

 ActiveRecord::StatementInvalid:
            PG::UntranslatableCharacter: ERROR:  unsupported Unicode escape sequence

so I'd prefer to just set these types of values to nil.