Views and Layouts
suggest changeWhen 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
peopleinapp/views/layouts/(orapplicationif no match is found) - a view called
index.html.erbinapp/views/people/by default - to render another file, such as
index_new.html.erb, callrender "index_new"fromPeopleController#index - set a different layout for an action with
render "index_new", layout: "your_layout_name"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents