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?

More than 3 years have passed since last update.

Railsのビューの基本中の基本

Posted at

Railsにおいて、ビューの基本は

app/assets/layouts/application.html.erb

を経由するということ。

逆に言えば、application.html.erbに記述していないと、仮にcontrollerとそれに対応するviewを作っても何も表示されません。

そのため、最低限、application.html.erbには下記の記述が必要です。

app/assets/layouts/application.html.erb
<%= yield %>

これを記述しておけば、各controllerに対応するviewを書いておけばそれぞれ呼び出されます。

これだけだと流石に、無駄が多いので、各種ビューを見て重複する部分はapplication.html.erbにまとめておけば良いと思います。
(例えばheadタグ要素とか。)

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?