partials and objects...?

I have this one partial _ownerselect.rhtml in my Computers Controller that has an instance var @computers.

I call the partial like:

   :partial =>' ownerselect', :object => computers

From inside the partial computers.location does not work. The only

working solution is ownerselect.location

Why on earth has the name of the partial replace that of the object passed to it?

Thanx!

when using the :object option, the name of the object in the partial takes the name of the partial. its part of the DRY principal in that you can reuse the partial without requiring the partial to know the name of the object you are passing to it. think of it like a method call. the method itself is not aware of the name of the parameter on the outside of the function.

def mymethod(arg)    # isn't aware of the name of the argument outside the function end

x = 1 mymethod(x)

say i have a partial named '_people_list.rhtml'

in one action i want to list all the people

@people = Person.find(:all) render :partial => "people_list", :object => @people

in another action i want to list just blond_haired_people

@bh_people = Person.find(:all, :conditions => "hair_color = 'blonde'") render :partial => "people_list", :object => @bh_people

then in my partial i just use people_list to refer to the object that was passed in and it will always work.