Serialized attributed with native hash is saved as !ruby/hash:ActiveSupport::HashWithIndifferentAcce

Hi, I have a Rails 3 application. I want to save multiple values in a filed. But when i save I have this error in the field

— !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nit: Padova\nde: Padovan\n

this is my html

My params

{“utf8”=>“✓”, “authenticity_token”=>“RvpwQw/RdTAT2d4jtaSyBAYRgT1mKgWg9kyrS7pUnMo=”, “person”=>{“birthplace”=>{“it”=>“Padova”, “de”=>“Padovan”}}, “commit”=>“Create Person”, “action”=>“create”, “controller”=>“people”}

I have another application where the data is save in this format for example

—\nit: Padova\nde: Padovan\n

and i don’t have any error.

If i put in the model

serialize :birthplace, Hash

is correct but i have a diffrent format {:it=>“Padova”,:de=>“Padovan”}

I read in the last part of this document

http://apidock.com/rails/ActiveRecord/AttributeMethods/Serialization/ClassMethods/serialize

that Yaml is the default serialization and generate a string —\n…

Any ideas?

This is the right thing to do. You don’t see the yaml in your app because rails is doing the conversion to/from yaml for you. If you were to look at your column with a non rails database tool then you would see the raw serialised data.

Fred