TemplateError for second-level partial during AJAX update.

Hi All,

Could someone please explain to me why I'm getting an
ActionView::TemplateError when I try to use AJAX to update the
interface while using the following code:

      <div id="building[<%=building.id%>][controls]">
    <%building.controls.each do |control|%>
      <%=render :partial => "control", :locals => {:control => control}%>
    <%end%>
  </div>

I have the following structure: Site -> Building -> Control. Each
loops through it's collection of items and renders a partial for
each. From Site to Building works just fine. However, going from
Building on to Control throws the template error.

It is noteworthy that Controls get added just fine, and if I refresh
the page, all the code works -- but for some reason when I try to do
the AJAX thing, the partial (not the "rjs" file) throws an error.

Any thoughts? My apologies if this is too vague.

Best.

check the location of template . this may be cause .

N A R E N

My apologies. Actually the error is that there is no method named
'controls'. In fact, this is the full error:

ActionView::TemplateError (undefined method `controls' for #<Control:
0x21f61f0>) on line #21 of app/views/site_manager/_building.html.erb:
18:
19: <!--Controls-->
20: <div id="building[<%=building.id%>][controls]">
21: <%for control in building.controls%>
22: <%=render :partial => "control", :locals => {:control =>
control}%>
23: <%end%>
24: </div>

    app/views/site_manager/_building.html.erb:21
    app/views/site_manager/add_control_to_building.rjs:1:in
`__instance_exec0'
    app/views/site_manager/add_control_to_building.rjs:1:in
`_run_rjs_app47views47site_manager47add_control_to_building46rjs'
    app/controllers/site_manager_controller.rb:23:in
`add_control_to_building'

Rendered rescues/_trace (56.4ms)
Rendered rescues/_request_and_response (1.5ms)
Rendering rescues/layout (internal_server_error)

check for
<%for control in building.controls%>

and make sure controls is defined

~N A R E N

You seem to have Control object itself stored in building variable and hence it does not have any controls method in it

Wow! Yeah, I was aware of what rails *thought* was the issue, but I
was also *sure* I was in the right. Turns out I was wrong. I'd copied
and pasted the "rjs" code into the new "rjs" file. When I did, I
missed the partial name and left it as "building", so it was passing a
"control" object back to the "building" partial when it should have
been passing it to the "control" partial. Thanks so much for letting
me talk out loud!