2014-04-17 32 views
1

我正在嘗試將地圖傳遞給屬性,並且發生此錯誤TypeError: can't convert Symbol into Integer。任何人都可以幫我理解爲什麼會這樣?'TypeError:無法將符號轉換爲整數'更新嵌套屬性時

此代碼一直工作,直到我從Heroku Bamboo遷移到Heroku Cedar(但Rails和Ruby的版本與特定版本相同(1.9.2p320 - > 1.9.2p321和Rails 3.0.20)

很明顯,它的發生,因爲這是由該行attribute_ids = attributes_collection.map {|a| a['id'] || a[:id] }.compact但處理的地圖「A」最終只返回一個字符串,並導致錯誤。

我包括正在被處理的地圖和堆棧跟蹤的錯誤。https://gist.github.com/akinsgre/10994359

回答

1

更新:

我有點想通了問題......現在我需要弄清楚如何修復現有的記錄。

nested_attributes在某些時候已經從has_one更改爲has_many;因此,「壞」的地圖有此

 
"party_attributes" => { 
       "profile" => "e04aaa50c9c3501de345fb9b468e53d5371e2e83e098bd2d67de4be39531616a" 
      } 

好的地圖有

 
"party_attributes" => { 
       "0" => { 
        "profile" => "e04aaa50c9c3501de345fb9b468e53d5371e2e83e098bd2d67de4be39531616a" 
       }, 
       "1" => { 
        "profile" => "8cdcde33e1315a77894d5a9601cff114b97dd5da9ca5f1c87ea7be3ea81398b3" 
       } 
+0

只是寫了一個函數抓取的哈希和修改記錄。 – Greg

相關問題