0
繼Mongoid documentation後,我試圖將一個哈希數組傳遞給create
方法,但它會引發錯誤。創建一批文檔時出錯
的代碼是:
Person.create([
{ first_name: "Heinrich", last_name: "Heine" },
{ first_name: "Willy", last_name: "Brandt" }
])
它引發以下錯誤:
NoMethodError: undefined method `keys' for #<Array:0xae4f69c>
運行:
mongoid-3.0.23
ruby 1.9.3
rails 3.2.13
完美的作品。非常感謝! – user1032752