Chao Lam

Working on the next small things …

Force legacy database using BLOBs to behave as utf-8 strings in rails

leave a comment »

I was working on a legacy mysql database which had a BLOB column “user_name”. I think it used a blog so that it could have emojis as strings (before utf8mb4?)

Anyway, my action mailer emails were failing when they encountered these emoji characters. ActiveRecord does all these magical things behind the scenes, but unfortunately it was magically convert the BLOB to 8-bit ASCII upon which action mailer barfed when it encountered these emoji characters.

Finding the issue was the hard part, the fix was easy:

  def user_name

Written by Pseudonymous

April 23, 2019 at 6:01 pm

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: