Forum: Ruby on Rails activerecord access raw 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.
3518ff338e5eee9b32eb1815daabc602?d=identicon&s=25 Marcelo Barbudas (Guest)
on 2009-02-01 14:33
(Received via mailing list)
Hi,

I have a model with a serialized field 'other_data'.

How can I add raw YAML data to that field?

If i try:
model[other_data] = yaml_formatted_data
yaml_formatted_data gets YAML formatted again.

--
cheers,
M.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-01 15:07
(Received via mailing list)
Marcelo Barbudas wrote:

> I have a model with a serialized field 'other_data'.
>
> How can I add raw YAML data to that field?
>
> If i try:
> model[other_data] = yaml_formatted_data
> yaml_formatted_data gets YAML formatted again.

I'm not sure why you don't want the serializer to do it for you. You
could also
try model.other_data = YAML::load(yaml_formatted_data)...

But try model.attributes[:other_data]!
This topic is locked and can not be replied to.