LoginSignup
0
1

More than 5 years have passed since last update.

railsで可変のURLを設定する際に気をつけること

Posted at

全体の流れ

ルーティング→コントローラ(アクション)→ビューの順で処理が行なわれる。

記述

routes.rb
get "posts/:id" => "posts#show"

上記でposts以下にidが来た際に全てshowアクションを実行します。

注意点

何が来てもshowを返してしまうためposts/の処理でshowを返したくない場合、上に記述しないといけない。上から順に処理されて当てはまるとその処理を行う。

routes.rb
get "posts/index" => "posts#index"
get "posts/:id" => "posts#show"
0
1
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
1