Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

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

#43

This example fails:

  1. @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

Reported by orangechicken · April 23rd, 2008 @ 10:19 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. keeran
    keeran

    Just put some tests together to see if this needed fixing. Looks like it doesn't. Please could someone check my tests?

    Kee

    April 24th, 2008 @ 08:44 PM

  2. orangechicken
    orangechicken

    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?

    April 24th, 2008 @ 09:48 PM

  3. keeran
    keeran

    Ah good point - sorry didn't notice the tagging. Checking it out now.

    April 25th, 2008 @ 06:02 PM

  4. keeran
    keeran

    Could try to pull some of the changes down, if they're nicely branched in git I guess...

    April 30th, 2008 @ 06:54 PM

  5. keeran
    keeran

    Could try to pull some of the changes down, if they're nicely branched in git I guess...

    April 30th, 2008 @ 06:55 PM

  6. DHH
    DHH
    • State changed from new to resolved

    April 30th, 2008 @ 10:05 PM

  7. Mark A. Richman
    Mark A. Richman

    Where would one put error_messages_for @article.feed? In feeds/_feed.html.erb or in articles/new.html.erb?

    May 28th, 2008 @ 03:33 PM