如何使用 ruby Grape 将多行发布到数据库中。例如,当使用 CURL 进行测试时,这工作正常
curl -H "Content-Type: application/json" -X POST \
-d '{"name": "test", "age": "22"}' http://localhost:3000/students
但这不起作用
curl -H "Content-Type: application/json" -X POST \
-d '[{"name": "test", "age": "22"}, {"name": "someone", "age": "32" }]' \
http://localhost:3000/students
这是我的葡萄 api 代码
post do
student = Student.new
student.name = params[:name]
student.age = params[:age]
student.save!
end