diff options
author | kenta-s <knt01222@gmail.com> | 2017-02-06 21:47:07 +0900 |
---|---|---|
committer | kenta-s <knt01222@gmail.com> | 2017-02-06 21:47:08 +0900 |
commit | 3ea926b86a209d67c210fc105cadcad73984e3e0 (patch) | |
tree | d14784f98c116620e7723ac0f2873a4e712d05e0 | |
parent | 2bbea8b0996a45f9bdfafe3b63f123cca4614e10 (diff) | |
download | rails-3ea926b86a209d67c210fc105cadcad73984e3e0.tar.gz rails-3ea926b86a209d67c210fc105cadcad73984e3e0.tar.bz2 rails-3ea926b86a209d67c210fc105cadcad73984e3e0.zip |
Add information on `:formats` option in action_view_overview.md
-rw-r--r-- | actionview/test/template/render_test.rb | 3 | ||||
-rw-r--r-- | guides/source/layouts_and_rendering.md | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index fbe0e555bd..412948719c 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -406,8 +406,7 @@ module RenderTestCases assert_equal "Before (Josh)\n\nAfter", @view.render(partial: "test/layout_for_partial", locals: { name: "Josh" }) end - # TODO: The reason for this test is unclear, improve documentation - def test_render_missing_xml_partial_and_raise_missing_template + def test_render_partial_with_non_existent_format_and_raise_missing_template @view.formats = [:xml] assert_raises(ActionView::MissingTemplate) { @view.render(partial: "test/layout_for_partial") } ensure diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index 293c99fc8f..5a3fadde40 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -411,6 +411,8 @@ render formats: :xml render formats: [:json, :xml] ``` +If a file with the specified extension does not exist, a `MissingTemplate` error will be raised. + #### Finding Layouts To find the current layout, Rails first looks for a file in `app/views/layouts` with the same base name as the controller. For example, rendering actions from the `PhotosController` class will use `app/views/layouts/photos.html.erb` (or `app/views/layouts/photos.builder`). If there is no such controller-specific layout, Rails will use `app/views/layouts/application.html.erb` or `app/views/layouts/application.builder`. If there is no `.erb` layout, Rails will use a `.builder` layout if one exists. Rails also provides several ways to more precisely assign specific layouts to individual controllers and actions. |