views:

620

answers:

1

I use serialize in one ActiveRecord model to serialize an Array of simple Hashes into a text database field. I even use the second parameter to coerce deserialization into Arrays.

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

It seems to work fine but, after a few requests, the content of recipients turns to HashOfIndifferentAccess hashes instead of arrays. This only happens after a few reloads of the models and I haven't been able to reproduce it in tests or the console, only in production environment.

A: 

I don't fully understand. You're getting back a HashWithIndifferentAccess filled with the Hashes you expected, or an Array filled with HashesWithIndifferentAccess? Are you getting serialization type mismatch errors, or just running into problems in your custom code? If there are any exceptions being thrown, it would be very helpful to include stack traces and error messages etc.

A. Morrow