我正在创建一个哈希数组并通过 json 将其传递给控制器。这是我发送的数据和之前的一些服务器输出:
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\":\"kirsten_gronberg@yahoo.com\"},{\"email\":\"dtsheahan@msn.com\"},{\"email\":\"clayton19361@hotmail.com\"},{\"email\":\"kumar.alka92@yahoo.com\"},{\"email\":\"j.eromes.n.d.c@gmail.com\\r\"},{\"email\":\"0\"},{\"email\":\"christine@colormepink.com\"},{\"email\":\"janabouc@gmail.com\"},{\"email\":\"carin@inkfoundry.com\"},{\"email\":\"jon.neiditz@nelsonmullins.com\"}]"}
这是我的控制器代码:
参数[“用户”].each { |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'
有人知道我在这里可能会发生什么错误吗?
谢谢!