Forum: Ruby on Rails Storing hashes in DB but getting strings back

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.
Ebac0be1687975b63a20da7b254442ab?d=identicon&s=25 Sebastian probst Eide (sebastianpe)
on 2007-05-02 13:06
Hi!
I am adding a hash to a serialized column in a DB. When retrieving the
data I get back a string though... Any idea why that might happen?

Here is the model and a copy and paste of the usage from irb:
http://pastie.caboo.se/58220

Hope you have any ideas!

Best regards
Sebastian
Ebac0be1687975b63a20da7b254442ab?d=identicon&s=25 Sebastian probst Eide (sebastianpe)
on 2007-05-02 13:19
I solved the problem.
Never mind.
I had written the serialize statement wrong.

I had written:
serialize :name1, :name2

but writing
serialize :name1, Hash
serialize :name2, Hash

solved the problem.
Tralala!

Thanks

S



Sebastian probst Eide wrote:
> Hi!
> I am adding a hash to a serialized column in a DB. When retrieving the
> data I get back a string though... Any idea why that might happen?
>
> Here is the model and a copy and paste of the usage from irb:
> http://pastie.caboo.se/58220
>
> Hope you have any ideas!
>
> Best regards
> Sebastian
This topic is locked and can not be replied to.