Notes posted by FesterRSS feed
It is possible to supply a class with own (de)serialization logic to the serialize call. Given object must respond to load and dump calls.
Following example serializes symbols into their string representation and store them in database as raw strings instead of their YAML representation, i.e. :pumpkin would be stored as ‘pumpkin’, and not as ‘--- :pumpkin\n’
clas SomeModel < ActiveRecord::Base class SymbolWrapper def self.load(string) string.to_sym end def self.dump(symbol) symbol.to_s end end serialize :value, SymbolWrapper end