Forum: Ruby on Rails Serialized data

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4954715b1fb1a61ba31b700542402599?d=identicon&s=25 mafloria (Guest)
on 2009-01-08 00:34
(Received via mailing list)
Hi,

I have a serialized Hash in a database. How can I acces my data? data
is stored as a varchar and text.
7cd9ea64fa126c4e38573828d43df911?d=identicon&s=25 Glen (Guest)
on 2009-01-08 02:16
(Received via mailing list)
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
This topic is locked and can not be replied to.