From 2636807dfbec2f0bf68fe3afe5df45eedeb88663 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Thu, 16 Oct 2008 18:57:15 -0500 Subject: More detail on partials. --- railties/doc/guides/actionview/layouts_and_rendering.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/railties/doc/guides/actionview/layouts_and_rendering.txt b/railties/doc/guides/actionview/layouts_and_rendering.txt index db6d8b3517..ed56b82ffd 100644 --- a/railties/doc/guides/actionview/layouts_and_rendering.txt +++ b/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: -- cgit v1.2.3