Why does ActiveRecord serialization accidentally distort my data?

I use serializein one model ActiveRecordto serialize Arraysimple hashes in a text database field. I even use the second parameter to force deserialization in Arrays.

class Shop < ActiveRecord::Base
  serialize : recipients, Array
end

Everything seems to be fine, but after a few requests, the content recipientsturns into hashes HashOfIndifferentAccessinstead of arrays. This happens only after several reboots of the models, and I could not reproduce them in tests or console, only in the working environment.

+3
source share
2 answers

Rails 3.1. . , SQLite, Postgres.

some_field.force_encoding(Encoding::UTF_8) , .

+2

, . .

. , .

, . , , HWIA , .

.

+1

Source: https://habr.com/ru/post/1697811/


All Articles