我试图模拟POST到我简单的Rails脚手架Web服务。脚手架创建的文件没有改变。当我从网站表单发布数据时,正确创建了一条记录。curl命令行POST
当我尝试使用curl进行POST时,数据库中会创建一条记录,但它的字段中有NULL值,'updated_at'和'created_at'除外。我是新来的命令行卷曲,所以我可能没有正确地做。
curl -d "name=Gazoo&friend=Rubble" localhost:3000/flintstones
我回来这从使用WEBrick:
开始POST “/摩登原始人” 为127.0.0.1,在周四04月28日18时04分47秒-0600 2011处理由FlintstonesController#创建为参数: {“name”=>“Gazoo”,“friend”=>“Rubble”} AREL(0.3ms)INSERT INTO“flintstones”(“name”,“friend”,“created_at”,“updated_at”)VALUES(NULL, NULL, '2011-04-29 00:04:47.779902', '2011-04-29 00:04:47.779902')重定向到http://localhost:3000/flintstones/4
后查看该JSON
卷曲本地主机:3000/flintstones.json
我收到:
[{ “打火石:{” 名 “:空,” created_at “:” 2011- 04-29T00:09:58Z“,”updated_at“:”2011-04-29T00:09:58Z“,”id“:4,”friend“:null}}]
为什么我会在我的空字段?
在此先感谢。
看来url参数没有传递给sql插入,而是NULL插入。 – 2011-04-29 00:51:27
这是正确的丹。我的问题是为什么? – Kurt 2011-04-29 01:14:40