I’ve been vacillating between using the :locals hash and instance
variables when passing data to partials. Is there a valid reason to use
one over the other? What could be considered a best practice in the
Rails community? I did some googling but didn’t turn anything up.
On Tue, Sep 30, 2008 at 7:54 AM, Phillip K. [email protected] wrote:
I’ve been vacillating between using the :locals hash and instance
variables when passing data to partials. Is there a valid reason to use
one over the other? What could be considered a best practice in the
Rails community? I did some googling but didn’t turn anything up.
As a general rule of thumb, you’ll want to be conservative when it
comes to scoping your variables. In my opinion, it’s best to use
locals and not rely on an instance variable.
Cheers,
Robby
–
Robby R.
Chief Evangelist, Partner
PLANET ARGON, LLC
design // development // hosting
I’ve always wondered if there’s a performance (or other) difference
between using an iterating partial (e.g. with :collection =>) vs. an
explicit iterator.