Serialized data


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

Did you use ActiveRecord’s serialization?

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

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

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

Thank you,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs