Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More detail on partials.

  • Loading branch information...
commit 2636807dfbec2f0bf68fe3afe5df45eedeb88663 1 parent 03626f0
@ffmike ffmike authored
Showing with 9 additions and 0 deletions.
  1. +9 −0 railties/doc/guides/actionview/layouts_and_rendering.txt
View
9 railties/doc/guides/actionview/layouts_and_rendering.txt
@@ -688,6 +688,15 @@ Every partial also has a local variable with the same name as the partial (minus
Within the +customer+ partial, the +@customer+ variable will refer to +@new_customer+ from the parent view.
+If you have an instance of a model to render into a partial, you can use a shorthand syntax:
+
+[source, html]
+-------------------------------------------------------
+<%= render :partial => @customer %>
+-------------------------------------------------------
+
+Assuming that the +@customer+ instance variable contains an instance of the +Customer+ model, this will use +_customer.html.erb+ to render it.
+
==== Rendering Collections
Partials are very useful in rendering collections. When you pass a collection to a partial via the +:collection+ option, the partial will be inserted once for each member in the collection:
Please sign in to comment.
Something went wrong with that request. Please try again.