product.properties[‘isbn’] = 32232323
product.properties[‘color’] = ‘blue’
product.save
id = product.id
…
p = Product.find(id)
p[‘color’] #=> ‘blue’
…
Product.hashfind_by_properties(‘isbn’, 32232323) #=> p
It’s useful when the properties you need to store are always changing,
so you can’t use field mapping, but you want to query by them, and so
can’t use serializable.
You can’t do SQL queries by fields of :serialize . You need to
instantiate all the objects into Ruby, and check them one by one, which
is slow (although it can be done in one line of code).
Not brilliant, and more or less untested, but better than pulling all
of the data from the server and parsing it application side. Very
simple to turn into a plugin, too.