Ruby on Rails Monday, May 23, 2016

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

<input type="text" size="25" name="person[birthplace[it]]" id="person_birthplace[it]" value="" > <input type="text" size="25" name="person[birthplace[de]]" id="person_birthplace[de]" value="" >

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?








--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/306fa0c5-ee24-4c41-9377-aed2356d83b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment