0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

postmanでpostリクエストを送り、createアクションを通じjsonで返すまで

Posted at

postmanで、postリクエストを送り、createアクションを通じてjsonで返すまで

postmanにpostのURLを入力

URLの下のバーから「body」を選択

下の「row」を選択

右端のタブの中から「json」を選択

入力フィールドにjson形式でデータを入力

projectモデルの、titleカラムとstatusの例
{
    "project": {
        "title": "first project",
        "status": "closed"
    }
}

これでpostリクエストを選択し、sendするとcreateアクションが実行され、jsonでデータが返ってくる。

DBにも正常にオブジェクトが保存されている。

irb(main):003:0> Project.all
  Project Load (0.7ms)  SELECT  "projects".* FROM "projects" WHERE "projects"."deleted_at" IS NULL LIMIT $1  [["LIMIT", 11]]
=> #<ActiveRecord::Relation [#<Project id: 3, title: "third p", deleted_at: nil, created_at: "2019-02-15 11:16:26", updated_at: "2019-02-15 11:16:26", status: "open">, #<Project id: 10, title: "test P", deleted_at: nil, created_at: "2019-02-16 00:21:14", updated_at: "2019-02-16 00:21:14", status: "closed">, #<Project id: 11, title: "test P", deleted_at: nil, created_at: "2019-02-16 00:21:17", updated_at: "2019-02-16 00:21:17", status: "closed">, #<Project id: 12, title: "test P", deleted_at: nil, created_at: "2019-02-16 00:22:07", updated_at: "2019-02-16 00:22:07", status: "closed">]>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?