title: rails partial doesn't receive variable
body: <p>My application has a Server and Domain modules such that server has_many domains and domain belongs_to server.</p>
  
  <p>I'm trying to render a partial in the Server controller:</p>
  
  <pre><code>  def get_domain_checkboxes
        @domains = Domain.find_by(:server_id =&gt; params[:id])  
        render :partial =&gt; 'servers/domain_checkboxes', :layout =&gt; nil
    end
  </code></pre>
  
  <p>The partial '_domain_checkboxes.html.erb' contains:</p>
  
  <pre><code>&lt;% @domains.each do |domain| %&gt;
      domain.url
  &lt;% end %&gt;
  </code></pre>
  
  <p>But I get an error when going to 'servers/3/get_domain_checkboxes' route and the trace says:</p>
  
  <pre><code>Started GET "/servers/3/get_domain_checkboxes" for ::1 at 2015-12-18 05:03:08 +0200
  Processing by ServersController#get_domain_checkboxes as HTML
    Parameters: {"server_id"=&gt;"3"}
    Domain Load (0.3ms)  SELECT  "domains".* FROM "domains" WHERE "domains"."server_id" IS NULL LIMIT 1
    Rendered servers/_domain_checkboxes.html.erb (1.4ms)
  Completed 500 Internal Server Error in 9ms (ActiveRecord: 0.4ms)
  
  ActionView::Template::Error (undefined method `each' for nil:NilClass):
      1: &lt;% @domains.each do |domain| %&gt;
      2:     hello
      3: &lt;% end %&gt;
    app/views/servers/_domain_checkboxes.html.erb:1:in `_app_views_servers__domain_checkboxes_html_erb___2806237560631891313_70206341448100'
    app/controllers/servers_controller.rb:71:in `get_domain_checkboxes'
  </code></pre>
  
  <p>Tried anything for past hour. Probably something simple that I'm missing?</p>
  
  <p>EDIT:</p>
  
  <p>Tried <code>@domains = Domain.find_by(:server_id =&gt; params[:server_id])</code>  instead but still get an error:</p>
  
  <pre><code>Started GET "/servers/3/get_domain_checkboxes" for ::1 at 2015-12-18 05:09:43 +0200
  Processing by ServersController#get_domain_checkboxes as HTML
    Parameters: {"server_id"=&gt;"3"}
    Domain Load (0.1ms)  SELECT  "domains".* FROM "domains" WHERE "domains"."server_id" = ? LIMIT 1  [["server_id", 3]]
    Rendered servers/_domain_checkboxes.html.erb (1.6ms)
  Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.1ms)
  
  ActionView::Template::Error (undefined method `each' for #&lt;Domain:0x007fb465810738&gt;):
      1: &lt;% @domains.each do |domain| %&gt;
      2:     hello
      3: &lt;% end %&gt;
    app/views/servers/_domain_checkboxes.html.erb:1:in `_app_views_servers__domain_checkboxes_html_erb___2806237560631891313_70206341448100'
    app/controllers/servers_controller.rb:71:in `get_domain_checkboxes'
  </code></pre>