This seems insane to me. We are upgrading our app from Rails 6.1.7.7 to rails 7.1.3.4 and ruby 3.3.2 to 3.3.4.
In our items model, we have a simple serializer:
serialize :keywords, coder: JSON, type: Array
We have millions of records stored using this form our 6.1.7.7 app and can write and read from it without issue:
Loading production environment (Rails 6.1.7.7)
irb(main):001> i = Item.find(4443084)
=>
#<Item:0x00007f6b6fb909d8
...
irb(main):002> i.keywords
=> "brain,web design,mind-blowing,development,vintage"
but when we attempt to read the EXACT same data using our Rails 7 app, it crashes:
Loading production environment (Rails 7.1.3.4)
irb(main):001> i = Item.find(4443084)
An error occurred when inspecting the object: #<JSON::ParserError:"unexpected token at '--- brain,web design,mind-blowing,development,vintagen'">
Result of Kernel#inspect: #<Item:0x00007f52b5e882d0 @new_record=false, @attributes=#<ActiveModel::LazyAttributeSet:0x00007f52b5ed0cd8 @attributes={"id"=>#<ActiveModel::Attribute::FromDatabase
...
I can’t seem to find anything on this at all! We used serialize in many places in our app and if we can’t read any of them in our Rails 7 app, we’re in trouble.
How do we fix this? Why would the same coder and type not work the same between the two?