Skip to content

Commit b3c4eca

Browse files
authored
Merge pull request rails#46342 from olivierlacan/docs/view-template
Improve missing template error page
2 parents c8fb918 + 9425191 commit b3c4eca

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<header role="banner">
2-
<h1>No template for interactive request</h1>
2+
<h1>No view template for interactive request</h1>
33
</header>
44

55
<main id="container">
66
<h2><%= h @exception.message %></h2>
77

8-
<p class="summary">
9-
<strong>NOTE!</strong><br>
10-
Unless told otherwise, Rails expects an action to render a template with the same name,<br>
11-
contained in a folder named after its controller.
12-
13-
If this controller is an API responding with 204 (No Content), <br>
14-
which does not require a template,
15-
then this error will occur when trying to access it via browser,<br>
16-
since we expect an HTML template
17-
to be rendered for such requests. If that's the case, carry on.
18-
</p>
8+
<div class="summary">
9+
<p>
10+
<strong>NOTE:</strong>Rails usually expects a controller action to render a view template with the same name.
11+
</p>
12+
<p>
13+
For example, a <code>BooksController#index</code> action defined in <code>app/controller/books_controller.rb</code> should have a corresponding view template
14+
in a file named <code>app/views/books/index.erb.html</code>.
15+
</p>
16+
<p>
17+
However, if this controller is an API endpoint responding with 204 (No Content), which does not require a view template because it doesn't serve an HTML response, then this error will occur when trying to access it with a browser. In this particular scenario, you can ignore this error.
18+
</p>
19+
<p>
20+
You can find more about view template rendering conventions in the <a href="https://guides.rubyonrails.org/layouts_and_rendering.html#rendering-by-default-convention-over-configuration-in-action">Rails Guides on Layouts and Rendering in Rails</a>.
21+
</p>
22+
</div>
1923
</main>

0 commit comments

Comments
 (0)