When a controller action is rendered, Rails will attempt to find a matching layout and view based on the name of the controller.
Views and layouts are placed in the app/views
directory.
Given a request to the PeopleController#index
action, Rails will search for:
- the layout called
people
inapp/views/layouts/
(orapplication
if no match is found) - a view called
index.html.erb
inapp/views/people/
by default - if you wish to render other file called
index_new.html.erb
you have to write code for that inPeopleController#index
action likerender 'index_new'
- we can set different
layouts
for everyaction
by writingrender 'index_new', layout: 'your_layout_name'