Activerecord access raw serialized data


#1

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.


#2

Marcelo B. 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]!