title: undefined method nil:NilClass ruby
body: <p>What I need to do is create a page where the user will type in a last name and the system will return information related to it. I keep receiving the error "undefined method `each' for nil:NilClass." I am stuck and can not debug it any help or guidance would be greatly appreciated.</p>
  
  <p>CODE FOR THE INPUT PAGE</p>
  
  <pre><code>&lt;%= form_tag(showcustcourses_custcoursesout_path, :controller =&gt; "showcustcourses", :action =&gt; "custcoursesout", :method =&gt; "post") do %&gt;
    &lt;div class="field"&gt;
      &lt;%= label_tag :Customer_Name %&gt;&lt;br /&gt;
      &lt;%= text_field_tag :customer_name_in %&gt;
    &lt;/div&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= submit_tag "Submit Customer Name" %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>CODE FOR THE CONTROLLER </p>
  
  <pre><code>class BookinController &lt; ApplicationController
  
    def bookin
    end
  
    def bookout
      @customer_name = params[:customer_name_in]
      @r = Customer.find_by_last(@customer_name)
      @rate_list = @r ? @r.rates : nil
    end
  end
  </code></pre>
  
  <p>CODE FOR THE OUTPUT PAGE (<code>&lt;% @customer_list.each do |m| %&gt;</code> is throwing the error)</p>
  
  <pre><code>&lt;h1&gt;Bookin#bookout&lt;/h1&gt;
  &lt;p&gt;Find me in app/views/bookin/bookout.html.erb&lt;/p&gt;
  
  &lt;center&gt;&lt;table width = 65% border = 1&gt; 
    &lt;tr&gt; &lt;th&gt; Customer Name&lt;/th&gt;&lt;th&gt; Room Number &lt;/th&gt;  &lt;th&gt; Cost &lt;/th&gt;&lt;/tr&gt;   
    &lt;% @customer_list.each do |m| %&gt;
      &lt;tr&gt; &lt;td&gt; &lt;%= m.name %&gt; &lt;/td&gt; &lt;td&gt; &lt;%= m.roomnumber %&gt; &lt;/td&gt; &lt;td&gt; &lt;%= m.cost %&gt; &lt;/td&gt; &lt;/tr&gt; 
    &lt;% end %&gt;
  &lt;/table&gt; &lt;/center&gt;&lt;br /&gt; &lt;br /&gt;
  </code></pre>