LoginSignup
11

More than 5 years have passed since last update.

rails console で Controller を呼ぶ際のtips

Posted at

GET

パラメータをつけたい場合

app.get "http://localhost:3000/api/users/login", {'user_id' => 1}
=> 200

POST

パラメータをつけたい場合

app.get "http://localhost:3000/api/users/list.json", {'type' => 1}
=> 200

リクエストヘッダをつけたい場合

app.get "http://localhost:3000/api/users/list.json", nil, {'HTTP_TOKEN' => "xxxxxxxxxxxx"}
=> 200

※第二引数はparams

レスポンスの内容をみたい場合

app.response.body

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
11