mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add information on :formats
option in action_view_overview.md
This commit is contained in:
parent
2bbea8b099
commit
3ea926b86a
2 changed files with 3 additions and 2 deletions
|
@ -406,8 +406,7 @@ module RenderTestCases
|
||||||
assert_equal "Before (Josh)\n\nAfter", @view.render(partial: "test/layout_for_partial", locals: { name: "Josh" })
|
assert_equal "Before (Josh)\n\nAfter", @view.render(partial: "test/layout_for_partial", locals: { name: "Josh" })
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: The reason for this test is unclear, improve documentation
|
def test_render_partial_with_non_existent_format_and_raise_missing_template
|
||||||
def test_render_missing_xml_partial_and_raise_missing_template
|
|
||||||
@view.formats = [:xml]
|
@view.formats = [:xml]
|
||||||
assert_raises(ActionView::MissingTemplate) { @view.render(partial: "test/layout_for_partial") }
|
assert_raises(ActionView::MissingTemplate) { @view.render(partial: "test/layout_for_partial") }
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -411,6 +411,8 @@ render formats: :xml
|
||||||
render formats: [:json, :xml]
|
render formats: [:json, :xml]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If a file with the specified extension does not exist, a `MissingTemplate` error will be raised.
|
||||||
|
|
||||||
#### Finding Layouts
|
#### 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.
|
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.
|
||||||
|
|
Loading…
Reference in a new issue