title: Rails: An elegant way to display a message when there are no elements in database
body: <p>I realized that I'm writing a lot of code similar to this one:</p>
  
  <pre><code>&lt;% unless @messages.blank? %&gt;
    &lt;% @messages.each do |message|  %&gt;
      &lt;%# code or partial to display the message %&gt;
    &lt;% end %&gt;
  &lt;% else %&gt;
    You have no messages.
  &lt;% end %&gt;
  </code></pre>
  
  <p>Is there any construct in Ruby and/or Rails that would let me skip that
  first condition? So that would be executed when iterator/loop won't enter even once? For
  example:</p>
  
  <pre><code>&lt;% @messages.each do |message| %&gt;
    &lt;%# code or partial to display the message %&gt;
  &lt;% and_if_it_was_blank %&gt;
    You have no messages.
  &lt;% end %&gt;
  </code></pre>