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 hash of the objects attributes and values. This is a much more reliable way to serialize a Ruby class with ActiveRecord.
Alan
29 July 2010