This project is archived and is in readonly mode.

#43 ✓resolved
orangechicken

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:

  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

Comments and changes to this ticket

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>

People watching this ticket

Attachments

Pages