aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@gmail.com>2016-09-13 08:06:03 -0400
committerGitHub <noreply@github.com>2016-09-13 08:06:03 -0400
commit16b1816b1ac2204ec8a88436b8b170d0356ee8e5 (patch)
tree187e511174ecde3f477b59b7f3b69674cdaea269 /guides/source
parent2b5ed618ed61ca14912f37f0fde747575a13f902 (diff)
parentb4a4860f1ec00d3111de2b4c888984bb385ecad5 (diff)
downloadrails-16b1816b1ac2204ec8a88436b8b170d0356ee8e5.tar.gz
rails-16b1816b1ac2204ec8a88436b8b170d0356ee8e5.tar.bz2
rails-16b1816b1ac2204ec8a88436b8b170d0356ee8e5.zip
Merge pull request #26478 from girishso/fix-guides-for-partial-render-as-option
fixed guide to add correct documentation for partial render 'as' option
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/action_view_overview.md14
1 files changed, 7 insertions, 7 deletions
diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md
index e11466e79f..ff0127522b 100644
--- a/guides/source/action_view_overview.md
+++ b/guides/source/action_view_overview.md
@@ -254,12 +254,6 @@ as if we had written:
<%= render partial: "product", locals: { product: @product } %>
```
-With the `as` option we can specify a different name for the local variable. For example, if we wanted it to be `item` instead of `product` we would do:
-
-```erb
-<%= render partial: "product", as: "item" %>
-```
-
The `object` option can be used to directly specify which object is rendered into the partial; useful when the template's object is elsewhere (e.g. in a different instance variable or in a local variable).
For example, instead of:
@@ -274,12 +268,18 @@ we would do:
<%= render partial: "product", object: @item %>
```
-The `object` and `as` options can also be used together:
+With the `as` option we can specify a different name for the said local variable. For example, if we wanted it to be `item` instead of `product` we would do:
```erb
<%= render partial: "product", object: @item, as: "item" %>
```
+This is equivalent to
+
+```erb
+<%= render partial: "product", locals: { item: @item } %>
+```
+
#### Rendering Collections
It is very common that a template will need to iterate over a collection and render a sub-template for each of the elements. This pattern has been implemented as a single method that accepts an array and renders a partial for each one of the elements in the array.