aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorDiogo Benicá <diogobenica@gmail.com>2015-01-21 23:52:44 -0200
committerDiogo Benicá <diogobenica@gmail.com>2015-01-21 23:52:44 -0200
commit8b18449c27336bb1861292ff1913df31cbe90f5f (patch)
treedf0f5520f8293d75a2e6050c44a538b62e1695a1 /guides/source
parente8460f8bbe73537897f2162d1cccda943d8c0f4a (diff)
downloadrails-8b18449c27336bb1861292ff1913df31cbe90f5f.tar.gz
rails-8b18449c27336bb1861292ff1913df31cbe90f5f.tar.bz2
rails-8b18449c27336bb1861292ff1913df31cbe90f5f.zip
Add :formats to options list of render documentation.
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/layouts_and_rendering.md12
1 files changed, 11 insertions, 1 deletions
diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md
index eb3c188d38..69d3f6e86c 100644
--- a/guides/source/layouts_and_rendering.md
+++ b/guides/source/layouts_and_rendering.md
@@ -316,12 +316,13 @@ NOTE: Unless overridden, your response returned from this render option will be
#### Options for `render`
-Calls to the `render` method generally accept four options:
+Calls to the `render` method generally accept five options:
* `:content_type`
* `:layout`
* `:location`
* `:status`
+* `:formats`
##### The `:content_type` Option
@@ -430,6 +431,15 @@ Rails understands both numeric status codes and the corresponding symbols shown
NOTE: If you try to render content along with a non-content status code
(100-199, 204, 205 or 304), it will be dropped from the response.
+##### The `:formats` Option
+
+Rails uses the format specified in request (or `:html` by default). You can change this adding the `:formats` option with a symbol or an array:
+
+```ruby
+render formats: :xml
+render formats: [:json, :xml]
+```
+
#### 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.