我正在創建一個哈希數組並通過json將其傳遞到控制器中。下面是我送的數據和一些服務器輸出前右它:Ruby on Rails - 無法在模型中存儲哈希陣列
Started POST "/api/user.json" for 127.0.0.1 at Wed Jun 27 18:52:32 -0400 2012
Processing by Api::UsersController#create as JSON
Parameters: {"accept"=>"json", "content_type"=>"json", "users"=>"[{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\\r\"},{\"email\":\"0\"},{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\"},{\"email\":\"[email protected]\"}]"}
這裏是我的控制器代碼:
PARAMS [「用戶」]每個{| user_params | ! User.create(user_params) }
,這裏是錯誤:
Completed 500 Internal Server Error in 2ms
NoMethodError (undefined method `keys' for #<String:0x10662d660>):
app/controllers/api/users_controller.rb:6:in `create'
app/controllers/api/users_controller.rb:5:in `each'
app/controllers/api/users_controller.rb:5:in `create'
有沒有人有任何想法可能錯在這裏是發生了嗎?
謝謝!
user_param在檢查時如何看起來像? –