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?

ルーティング表の見方

0
Last updated at Posted at 2026-02-08

スクリーンショット 0008-02-08 15.10.23.png

スクリーンショット 0008-02-08 15.15.15.png
右端:Controller#Actionの内容

1. Prefix(接頭辞)

意味: パスを簡単に書くための「ニックネーム」です。

使い方: 末尾に _path をつけて、コントローラーやビューで使います。

例: root なら root_path、item なら item_path と書けます。

2.Verb(HTTPメソッド)

意味: そのURLに対して「どんな操作」をするのかという動詞です。

主な種類:

GET: 画面を表示する、データを取得する。

POST: 新しくデータを保存する(create アクションなど)。

PATCH / PUT: データを更新する。

DELETE: データを削除する。

3.URI Pattern(URLの形)

意味: ブラウザの住所欄に表示される実際のURLのパターンです。

例: /items/new や、特定のデータを指す /items/:id など。

4. Controller#Action(対応する処理)

意味: そのURLにアクセスした時、どのコントローラーの、どのアクション(メソッド)を動かすかを示しています。

成功時のフローと照らし合わせると https://qiita.com/358TECH-CAMP/items/e1ff572a6da2b85ae0b5
「成功時のリダイレクト」では、以下のように使われています。

保存時: Verb が POST、URI Pattern が /items の行を探し、items#create を実行します。

移動時: redirect_to root_path の root は、この表の Prefix にある root を参照して、「/(トップページ)へ行け」と翻訳されています。

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?