The existing solutions for this question not helps.
Rails: 5.2
ruby : 2.4.1
pg: 0.18
This is the query from the rails log:
INSERT INTO "users" ("first_name") VALUES ('\xC3\r\x04\t\x03\x02qlF\xA4\.....')
first_name
value is encrypted using active_record-pgcrypto
gem
first_name
is string
datatype in users
table
copy paste the query in pgAdmin works well. But the application throw the error.
As mentioned in the pgcrypto install documentation encrypted data should use a :binary
column. Otherwise Rails and Postgres will interpret it as UTF-8 characters, and some combinations of bytes are not valid UTF-8 characters.