Message from discussion
Proposal: partials should not create a local variable with the name of the partial when no :local or :object option was passed
Received: by 10.66.77.39 with SMTP id p7mr1931059paw.0.1348432757899;
Sun, 23 Sep 2012 13:39:17 -0700 (PDT)
X-BeenThere: rubyonrails-core@googlegroups.com
Received: by 10.68.226.100 with SMTP id rr4ls2145573pbc.2.gmail; Sun, 23 Sep
2012 13:39:12 -0700 (PDT)
Received: by 10.66.83.40 with SMTP id n8mr1652956pay.42.1348432752867;
Sun, 23 Sep 2012 13:39:12 -0700 (PDT)
Received: by 10.66.83.40 with SMTP id n8mr1652955pay.42.1348432752855;
Sun, 23 Sep 2012 13:39:12 -0700 (PDT)
Return-Path: <aa...@tenderlovemaking.com>
Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42])
by gmr-mx.google.com with ESMTPS id g4si2276131paw.1.2012.09.23.13.39.12
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 23 Sep 2012 13:39:12 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.160.42 is neither permitted nor denied by best guess record for domain of aa...@tenderlovemaking.com) client-ip=209.85.160.42;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.160.42 is neither permitted nor denied by best guess record for domain of aa...@tenderlovemaking.com) smtp.mail=aa...@tenderlovemaking.com
Received: by pbbro2 with SMTP id ro2so2684437pbb.15
for <rubyonrails-core@googlegroups.com>; Sun, 23 Sep 2012 13:39:12 -0700 (PDT)
d=google.com; s=20120113;
h=sender:date:from:to:subject:message-id:references:mime-version
:content-type:content-disposition:in-reply-to:user-agent
:x-gm-message-state;
bh=bzWQAVHMbW5hEurqdZ/0Xl6GRspoReqarsk80CGNiJc=;
b=cmXXSJqgbsopSTK9192HSIBNGgtFdHUUW4o+PkU7H6S+aXvA0dAV5JR/QSXeNTbkCR
02lsdOb8Ew3F66zUcpmz0aQm6kXZfHcajWUpoBwVIrwqLBytntBviWc/4HEi5HTbDYT/
K1QsTMCCO+c1pJ1/mroBsEkaVf9bimCksvBhp8zNii7fDXvWvK6BheT37OJYMq633jkX
5QgvNByDzl8Vw0+USuUiBTSbvoBhtailfSsE2RxWFDqthBnAqK4Cd6jcD4ct/eOChz6e
zxOENSS4rryVoksu94exKr/PTrFDR0iGXl5LmIaxiLrcb1azzMY8h2gPx4v6tVtAaoUf
LlXA==
Received: by 10.68.138.131 with SMTP id qq3mr31294968pbb.47.1348432752774;
Sun, 23 Sep 2012 13:39:12 -0700 (PDT)
Return-Path: <aa...@tenderlovemaking.com>
Received: from higgins.local (c-66-235-47-187.sea.wa.customer.broadstripe.net. [66.235.47.187])
by mx.google.com with ESMTPS id e8sm7574855pay.13.2012.09.23.13.39.11
(version=TLSv1/SSLv3 cipher=OTHER);
Sun, 23 Sep 2012 13:39:12 -0700 (PDT)
Sender: Aaron Patterson <aa...@tenderlovemaking.com>
Date: Sun, 23 Sep 2012 13:39:10 -0700
From: Aaron Patterson <tenderl...@ruby-lang.org>
To: rubyonrails-core@googlegroups.com
Subject: Re: [Rails-core] Proposal: partials should not create a local
variable with the name of the partial when no :local or :object option was
passed
Message-ID: <20120923203910.GC25...@higgins.local>
References: <fb2afa75-c379-446a-b4d4-5b6ed4f8e452@googlegroups.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature"; boundary="f+W+jCU1fRNres8c"
Content-Disposition: inline
In-Reply-To: <fb2afa75-c379-446a-b4d4-5b6ed4f8e452@googlegroups.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Gm-Message-State: ALoCoQn4xpvi/3fXjyPYMuJfTv+clBOWm/G+CpdD4Omlm8OTco5frXR1Y45RBaKB+z1mNgF2+CV+
--f+W+jCU1fRNres8c
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Sep 18, 2012 at 12:01:59PM -0700, John Firebaugh wrote:
>=20
>=20
> From this stack overflow question<http://stackoverflow.com/questions/3111=
844/flash-messages-in-partials-rails-3/12482879>
> .
>=20
> Suppose I have a partial _flash.html.erb for rendering the flash in a=20
> consistent way. The natural thing to do would be to assume I can call=20
> ActionView::Base#flash from within this partial to retrieve the flash, an=
d=20
> render the partial withrender partial: "flash". But in fact, this doesn't=
=20
> work. Even though I haven't passed object: flash orlocals: {flash: flash}=
in=20
> the call to render partial, PartialRenderer oh-so-helpfully defines a fla=
shlocal=20
> variable, whose value is nil, shadowing ActionView::Base#flash. My=20
> alternatives are to rename the partial or pass a value for the flash loca=
l=20
> explicitly using one of those more verbose call to render.
>=20
> I suggest that if no object option or local with the same name as the=20
> partial was passed to the render call, thatPartialRenderer *not* define a=
=20
> local variable of the same name as the partial. This would change the=20
> behavior for anyone who is relying on the current behavior to get a nil v=
alue=20
> for the local when they don't pass an explicit value, but that seems like=
=20
> an unlikely case and easily fixed by passing nil explicitly, and it would=
=20
> be much more useful to do things like call ActionView::Base#flash from=20
> within a _flash.html.erb partial.
>=20
> I'm happy to create a pull request if others agree.
Do you know where the code is that does this? I'd like to understand
why we do it before agreeing / disagreeing.
--=20
Aaron Patterson
http://tenderlovemaking.com/
--f+W+jCU1fRNres8c
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Darwin)
iQEcBAEBAgAGBQJQX3NuAAoJEJUxcLy0/6/GDpgH/j4b6nHl+C1jpedeEkaTt7qb
iBDbrrQotuelu0RIrUupZPUOFPvMGsYExg72YaNU58F8yD/zRq4nkcHlS+HBABbH
S/JGEE3AMHFbuD2lvRxlMiZZOY10aKAXWPghbigPktWjd8dB66l6G8MLFHT/kMAc
+8YRyiS6r2J38HQGYSBdst9Z5bk34Te/U7h9Fu4QOFEwdi3/tcU049rbmQBddzBw
BalW/Ki0DvXJ+dpYqbf3N9zj9B3boTCSv9iIw9LZpfseKBHjIZO9vJ4YCoYwzj4w
VAO/du/tMFYZTWjclmMQ+KE0qGrX86XRDQsxYc1TIOz7eslRkA+lUsMy8aYpwf8=
=AQ3N
-----END PGP SIGNATURE-----
--f+W+jCU1fRNres8c--