diff options
author | Mike Gunderloy <MikeG1@larkfarm.com> | 2008-10-16 18:57:15 -0500 |
---|---|---|
committer | Mike Gunderloy <MikeG1@larkfarm.com> | 2008-10-16 18:57:42 -0500 |
commit | 2636807dfbec2f0bf68fe3afe5df45eedeb88663 (patch) | |
tree | 8726d8f217734e6906cacbc82f4b6b699cbb4a27 /railties/doc/guides/actionview/layouts_and_rendering.txt | |
parent | 03626f0c13c0205becf04d8a47ee1e9bf4b80cb4 (diff) | |
download | rails-2636807dfbec2f0bf68fe3afe5df45eedeb88663.tar.gz rails-2636807dfbec2f0bf68fe3afe5df45eedeb88663.tar.bz2 rails-2636807dfbec2f0bf68fe3afe5df45eedeb88663.zip |
More detail on partials.
Diffstat (limited to 'railties/doc/guides/actionview/layouts_and_rendering.txt')
-rw-r--r-- | railties/doc/guides/actionview/layouts_and_rendering.txt | 9 |
1 files changed, 9 insertions, 0 deletions
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: |