This project is archived and is in readonly mode.
Render partial with record doesn't assign given record to local variable if instance variable doesn't exist
Reported by orangechicken | April 23rd, 2008 @ 10:19 PM
This example fails:
- @article has_one :feed
render :partial => @article.feed
The expected behavior is that @article.feed is assigned to the local variable :feed when rendering feeds/_feed.html.erb.
The correct template is found and rendered, it's just that the feed local variable is nil since no instance variable @feed exists.
The (bummer of a) workaround is this:
render :partial => @article.feed, :locals => {:feed => @article.feed}
It's a bummer because all the needed information is given to the first render_partial call above
Comments and changes to this ticket
-
keeran April 24th, 2008 @ 08:44 PM
Just put some tests together to see if this needed fixing. Looks like it doesn't. Please could someone check my tests?
Kee
-
orangechicken April 24th, 2008 @ 09:48 PM
If that test passes, then I'd say it's fixed in trunk but not in 2-0-stable, since the test is doing just what my expectation is.
Anyone know if there was a fix affecting this that could be ported to 2-0-stable?
-
keeran April 25th, 2008 @ 06:02 PM
Ah good point - sorry didn't notice the tagging. Checking it out now.
-
keeran April 30th, 2008 @ 06:54 PM
Could try to pull some of the changes down, if they're nicely branched in git I guess...
-
keeran April 30th, 2008 @ 06:55 PM
Could try to pull some of the changes down, if they're nicely branched in git I guess...
-
DHH April 30th, 2008 @ 10:05 PM
- State changed from new to resolved
http://github.com/rails/rails/co... is passing.
-
Mark A. Richman May 28th, 2008 @ 03:33 PM
Where would one put error_messages_for @article.feed? In feeds/_feed.html.erb or in articles/new.html.erb?
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>