Skip to content

Commit

Permalink
Add warning about deprecated partials behavior to Layout/Rendering Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Gunderloy authored and Mike Gunderloy committed Nov 1, 2008
1 parent 1d84c15 commit 82f46da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion railties/doc/guides/html/layouts_and_rendering.html
Expand Up @@ -1225,7 +1225,7 @@ <h4 id="_passing_local_variables">3.4.4. Passing Local Variables</h4>
&lt;% end %&gt;
</tt></pre></div></div>
<div class="para"><p>Although the same partial will be rendered into both views, the label on the submit button is controlled by a local variable passed into the partial.</p></div>
<div class="para"><p>Every partial also has a local variable with the same name as the partial (minus the underscore). By default, it will look for an instance variable with the same name as the partial in the parent. You can pass an object in to this local variable via the <tt>:object</tt> option:</p></div>
<div class="para"><p>Every partial also has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the <tt>:object</tt> option:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
Expand All @@ -1234,6 +1234,14 @@ <h4 id="_passing_local_variables">3.4.4. Passing Local Variables</h4>
<pre><tt>&lt;%= render :partial =&gt; "customer", :object =&gt; @new_customer %&gt;
</tt></pre></div></div>
<div class="para"><p>Within the <tt>customer</tt> partial, the <tt>@customer</tt> variable will refer to <tt>@new_customer</tt> from the parent view.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">In previous versions of Rails, the default local variable would look for an instance variable with the same name as the partial in the parent. This behavior is deprecated in Rails 2.2 and will be removed in a future version.</td>
</tr></table>
</div>
<div class="para"><p>If you have an instance of a model to render into a partial, you can use a shorthand syntax:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 2.9
Expand Down
4 changes: 3 additions & 1 deletion railties/doc/guides/source/layouts_and_rendering.txt
Expand Up @@ -806,7 +806,7 @@ _form.html.erb:

Although the same partial will be rendered into both views, the label on the submit button is controlled by a local variable passed into the partial.

Every partial also has a local variable with the same name as the partial (minus the underscore). By default, it will look for an instance variable with the same name as the partial in the parent. You can pass an object in to this local variable via the +:object+ option:
Every partial also has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the +:object+ option:

[source, html]
-------------------------------------------------------
Expand All @@ -815,6 +815,8 @@ 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.

WARNING: In previous versions of Rails, the default local variable would look for an instance variable with the same name as the partial in the parent. This behavior is deprecated in Rails 2.2 and will be removed in a future version.

If you have an instance of a model to render into a partial, you can use a shorthand syntax:

[source, html]
Expand Down

0 comments on commit 82f46da

Please sign in to comment.