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.

partial locals do not accept a string constant

#4620

When I try to set a locals variable to a string in a partial render, it doesn't get assigned properly. If I instead use an intermediate variable, it works.

View file: <%= render :partial => 'partial', :locals => {:who => 'me'} %>

Partial file: <%= @who %>

Result: empty string

Expected result: 'me'

Work-around view file: <% @who => 'me' %><%= render :partial => 'partial', :locals => {:who => @who} %>

The ActionView::Partials docs don't mention that the targets have to be variables, but that appears to be the case.

The ActionController::Base docs show an example using a string: render :partial => "person", :locals => { :name => "david" }

Reported by Craig Buchek · May 16th, 2010 @ 08:05 PM

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

Activity

  1. Matt Jones
    Matt Jones
    • State changed from new to invalid

    Did you happen to notice whilst reading the ActionView::Base docs that :locals are passed as local variables (no sigil) rather than instance variables (@ sigil)?

    May 16th, 2010 @ 10:06 PM