Let's deconstruct the error you get:
ActionView::TemplateError (undefined method `controls' for #) on line #21 of app/views/site_manager/_building.html.erb
The first part ActionView::TemplateError
is just the type of exception raised and not really interesting in this case. The next part is, however:
undefined method `controls' for #<Control:0x21f61f0>
This basically tells you that you're trying to call a method called controls
on an object that's an instance of the Control model. It also tells you that the controls
method is not defined on that instance.
on line #21 of app/views/site_manager/_building.html.erb
The above tells you where to find the source of this error, namely line 21 in the site_manager/building partial. That line looks like:
<%for control in building.controls%>
In that line you're trying to call a controls
method on a variable, which is what isn't working according to the error message; the controls
method is undefined on that variable. The error message also told you that the variable contains an instance of your Control model.
Now, you've named the variable building
, but it contains an instance of Control, which leads me to believe that you've somehow put another value into the building
variable than you intended.
Unfortunately, you don't show the code that assigns the value to the building
variable, so I can't get any closer to a real answer for you. Hopefully the above is enough to lead you to a solution.