1

基本上,我将 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,它给了我一个字符串。如果我YAML.load(serialized_string)按照以下答案 rails 错误的指示尝试在“psych”或“syck”中 运行,则无法解析 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'

使用“心理”引擎时的类似结果。有什么线索吗?

以下是字符串格式的哈希示例:

"--- !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"
4

1 回答 1

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,因为它以未终止的字符串结尾。

于 2012-05-21T23:59:54.407 回答