0
0

More than 1 year has passed since last update.

[Rails] トップページへのルーティングの設定方法

Last updated at Posted at 2022-10-08

ルートパスの記述方法

config/routes.rb
root to: 'コントローラー名#アクション名'

これでトップページを表示できます。
例 :

config/routes.rb
Rails.application.routes.draw do
  root to: 'schedules#index'
end

上記の例では、schedulesコントローラーのindexアクションに遷移するという意味になります。

viewでの使用例

layous/application.html.erb
<body>
  <header>
    <%= link_to "SCHEDULE", root_path %>
  </header>
</body>
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