Partial :object vs instance var

I'm questioning what appears to be a recommendation that makes no sense
in AWDWR 2nd Ed. I get the point being made, but the actual
convention/implementation seems to make the point ineffective.

  -- In the layout, we have access to the @cart instance variable that
was set by the controller. It turns out that this is also available
inside partials called from the layout. However, this is a bit like
calling a method and passing it some value in a global variable. It
works, but it's ugly coding, and it increases coupling (which in turn
makes your programs brittle and hard to maintain).

This is a good point. I don't recommend using instance variables in
partials. Everything should be passed to the partial from the
template. Treat a partial like a subroutine that can be called in
different contexts and that you pass arguments to.

You can do that, but it would be


Preferred is to pass multiple values using :locals

  render :partial => 'x', :locals => {:infoA => objectA, :infoB => objectB}

Then in the partial, you have reference separate variables:


May I use :collection and :locals together to handle parameters while
rendering partial?