title: Ruby on Rails each iteration error when one record
body: <p>I am stuck on what seems should have a very simple solution, but I can not find anything that will work!  I am iterating results from a table on the index page (which returns a list of states).  This works without any problems when multiple records are returned.  However, when a single record is returned, I get an error: undefined method 'each' for #  </p>
  
  <p>I know it is causing the error when only one record is returned, but I can not find any documentation on how to handle this, especially in the case that 1 or 0 records could be returned.</p>
  
  <p>Code in controller:</p>
  
  <pre><code>@states = State.find(params[:id])
  </code></pre>
  
  <p>Code in index page:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;% @states.each do |state| %&gt;
      &lt;li&gt;
        &lt;%= state.state_name %&gt;
      &lt;/li&gt;
    &lt;% end %&gt;
  &lt;/ul&gt;
  </code></pre>