基本上,我将1.8.7@rails2应用程序升级到1.9.3@rails3.2
尝试在序列化哈希上使用.each_pair
时,我最终得到
syntax error, unexpected ',', expecting keyword_end
@measure.coefficients.each_pair |key, value|
当尝试访问rails控制台以加载measure.coefficients
时,它会给我一个字符串。如果我按照以下答案的指示尝试在“psych”或“syck”中运行YAML.load(serialized_string)
rails error, couldn't parse YAML
我最终得到了
ArgumentError: syntax error on line 21, col 5: `'
from /Users/user/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/syck.rb:135:in `load'
使用'psych'引擎时的类似结果。 Anyclue?
以下是字符串格式的哈希示例:
"--- !map:HashWithIndifferentAccess \n\"1092\": \"\"\n\"869\": \"\"\n\"1039\": \"\"\n\"2492\": \"\"\n\"1389\": \"\"\n\"1200\": \"\"\n\"600\": \"\"\n\"1928\": \"\"\n\"1767\": \"\"\n\"1498\": \"\"\n\"899\": \"\"\n\"711\": \"\"\n\"1124\": \"\"\n\"1312\": \"\"\n\"1500\": \"\"\n\"900\": \"\"\n\"1152\": \"\"\n\"1232\": \"\"\n\"1340\": \"\"\n\"1420\": \"\"\n\"123"
答案 0 :(得分:1)
当您实际打印该值时,它会产生:
--- !map:HashWithIndifferentAccess
"1092": ""
"869": ""
"1039": ""
"2492": ""
"1389": ""
"1200": ""
"600": ""
"1928": ""
"1767": ""
"1498": ""
"899": ""
"711": ""
"1124": ""
"1312": ""
"1500": ""
"900": ""
"1152": ""
"1232": ""
"1340": ""
"1420": ""
"123
这显然不是有效的YAML,因为它以未终止的字符串结束。