Tag Archives: activerecord serialization example

Don’t serialize ActiveRecord objects

ActiveRecord provides a convenient interface for serializing Ruby objects. In the model file, simply declare which column will store the object:

All seems fine until you actually have to retrieve some of the data:

This isn’t the exact code situation I was in, but it’s similar enough.
Here’s how I solved the problem:

The attributes method call returns a [...]