Ruby中使用patch HTTP方法
Ruby中使用patch HTTP方法
如果使用patch,在后台可以看到只更新了改动的部分;
Started PATCH "/ads/5/update" for ::1 at 2017-04-20 20:12:40 +0800
Processing by AdsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"bOnqooQydWJaKHET09i/Kho52m2t
7CXgPlVgkjQW4iC2v5NZIEoBtk8Va7/sB5hDmQKhFLa/q32sTAnjtQJ1Vg==", "ad"=>{"name"=>"e
1", "description"=>"e", "price"=>"5.0", "seller_id"=>"5", "email"=>"e", "img_url
"=>"e"}, "commit"=>"Update1", "id"=>"5"}
Ad Load (1.0ms) SELECT "ads".* FROM "ads" WHERE "ads"."id" = ? LIMIT ? [["i
d", 5], ["LIMIT", 1]]
(1.0ms) begin transaction
SQL (1.0ms) UPDATE "ads" SET "name" = ?, "updated_at" = ? WHERE "ads"."id" =
? [["name", "e1"], ["updated_at", 2017-04-20 12:12:40 UTC], ["id", 5]]
(154.2ms) commit transaction
Redirected to http://localhost:3000/ads/5
Completed 302 Found in 165ms (ActiveRecord: 157.2ms)

浙公网安备 33010602011771号