Serialized data


#1

Hi,

I have a serialized Hash in a database. How can I acces my data? data
is stored as a varchar and text.


#2

Did you use ActiveRecord’s serialization?

class MyModel < ActiveRecord::Base
serialize :data, Hash
end

If so, you can simple call from your model to get your hash back.

mymodel = MyModel.find(prams[:id])
myhash = mymodel.data
field1 = myhash[:field1]

Thank you,
Glen