From 6363b286a34d8609d618e9dbdfd27cbd5ac6b29c Mon Sep 17 00:00:00 2001
From: Paul Kelly <pikelly@blueyonder.co.uk>
Date: Wed, 28 Apr 2010 17:01:57 +0100
Subject: [PATCH] Fixes #223

---
 app/controllers/hosts_controller.rb               |    3 ---
 app/views/hosts/_architecture.html.erb            |    4 ++--
 app/views/hosts/_form.html.erb                    |    2 +-
 app/views/hosts/_operatingsystem.html.erb         |    4 ++--
 app/views/hosts/_unattended.html.erb              |    2 +-
 app/views/puppetclasses/_class_selection.html.erb |    2 +-
 6 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb
index 6a20117..9630d7d 100644
--- a/app/controllers/hosts_controller.rb
+++ b/app/controllers/hosts_controller.rb
@@ -51,9 +51,6 @@ class HostsController < ApplicationController
 
   def edit
     @host = Host.find(params[:id])
-    @environment = @host.environment
-    @architecture = @host.architecture
-    @operatingsystem = @host.operatingsystem
   end
 
   def update
diff --git a/app/views/hosts/_architecture.html.erb b/app/views/hosts/_architecture.html.erb
index 7c8c324..f4be12a 100644
--- a/app/views/hosts/_architecture.html.erb
+++ b/app/views/hosts/_architecture.html.erb
@@ -1,7 +1,7 @@
 <%= label :host, :operatingsystem, "Operating system" %>
-<%= collection_select :host, :operatingsystem_id, @architecture.operatingsystems, :id, :to_label, :include_blank => true %>
+<%= collection_select :host, :operatingsystem_id, @host.architecture.operatingsystems, :id, :to_label, :include_blank => true %>
 <span id=os_sub_select>
-  <% if @operatingsystem -%>
+  <% if @host.operatingsystem -%>
     <%= render :partial => 'operatingsystem' %>
   <% end -%>
 </span>
diff --git a/app/views/hosts/_form.html.erb b/app/views/hosts/_form.html.erb
index 1be4617..babd7e1 100644
--- a/app/views/hosts/_form.html.erb
+++ b/app/views/hosts/_form.html.erb
@@ -14,7 +14,7 @@
    <%= link_to_function "Additional Classes", toggle_div(:classlist) %>
 
    <div id="classlist", style=display:none;>
-     <% if @environment -%>
+     <% if @host.environment -%>
        <%= render 'puppetclasses/class_selection', :obj => @host %>
      <% else -%>
        <b>Please select an Environment first</b>
diff --git a/app/views/hosts/_operatingsystem.html.erb b/app/views/hosts/_operatingsystem.html.erb
index c9fa6db..75afbb5 100644
--- a/app/views/hosts/_operatingsystem.html.erb
+++ b/app/views/hosts/_operatingsystem.html.erb
@@ -1,4 +1,4 @@
 <%= label :host, :media %>
-<%= collection_select :host, :media_id, @operatingsystem.medias, :id, :to_label %>
+<%= collection_select :host, :media_id, @host.operatingsystem.medias, :id, :to_label %>
 <%= label :host, :ptable, "Partition Table" %>
-<%= collection_select :host, :ptable_id, @operatingsystem.ptables, :id, :to_label %>
+<%= collection_select :host, :ptable_id, @host.operatingsystem.ptables, :id, :to_label %>
diff --git a/app/views/hosts/_unattended.html.erb b/app/views/hosts/_unattended.html.erb
index 30902f0..ec5dfc7 100644
--- a/app/views/hosts/_unattended.html.erb
+++ b/app/views/hosts/_unattended.html.erb
@@ -13,7 +13,7 @@
       <%= f.label :architecture %>
       <%= f.collection_select :architecture_id, Architecture.all, :id, :to_label, :include_blank => true %>
       <span id="host_os">
-        <% if @architecture -%>
+        <% if @host.architecture -%>
           <%= render "architecture" -%>
         <% end -%>
       </span>
diff --git a/app/views/puppetclasses/_class_selection.html.erb b/app/views/puppetclasses/_class_selection.html.erb
index 0a04714..b5b9f00 100644
--- a/app/views/puppetclasses/_class_selection.html.erb
+++ b/app/views/puppetclasses/_class_selection.html.erb
@@ -19,7 +19,7 @@
         </td>
 
         <%= render :partial => "puppetclasses/classes", :locals =>
-        {:puppetclasses => (obj.is_a?(Host) ? @environment.puppetclasses : Puppetclass.all) - obj.all_puppetclasses, :type => obj.class.to_s.downcase } %>
+        {:puppetclasses => (obj.is_a?(Host) ? @host.environment.puppetclasses : Puppetclass.all) - obj.all_puppetclasses, :type => obj.class.to_s.downcase } %>
     </tr>
   </table>
 <% end -%>
-- 
1.6.3.3

