LoginSignup
0
2

More than 5 years have passed since last update.

railsでページが表示されるまでの流れ(ルーティング→コントローラ→view)

Last updated at Posted at 2017-07-24

railsでページが表示されるまでの流れは以下

  • URLがリクエストされる
  • ルーティングでコントローラが指定
  • コントローラでアクションを呼び出す
  • アクションからviewへ

URLがリクエストされる→ルーティングでコントローラ指定

routs.rb

Rails.application.routes.draw do
 get "home/top" => "home#top"
 # get URL => コントローラ名#アクション名
end

Rails.application.routes.draw do〜endがルートを設定する記述

コントローラでアクションを呼び出す

アクションとは

アクションというのはコントローラ上のメソッドでここでは下記のようなものを指す。

これでルーティングが

get "URL" => "コントローラ名#アクション名"

の場合下記のdef top内の処理を呼び出す。

test
class test < test

def top
end

end

0
2
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
2