This looks wrong, but it works... what is right way?

<% if @base_coverages != nil %> <% if @base_coverages.length > 0 %> <table>   <% @base_coverages.each do |i| %>     <tr class="<%= cycle("even","odd") %>">       <td><%= i.coverage_id %></td>       <td><%= i.external_description %></td>     </tr>     <% end %> </table> <% end %> <% end %>

- Base coverages may be nil - Base coverages may have a length of 0

How do I clean this code up?

Thanks, Jason

How about this (not much different):

<% if !@base_coverages.blank? %> <table>   <% @base_coverages.each do |i| %>   <tr<%= cycle(' class="odd"','') %>>     <td><%= i.coverage_id %></td>     <td><%= i.external_description %></td>   </tr>   <% end %> </table> <% end %>

Regards, Rimantas

<...>

You could pull the <table> into a partial and end up with

<%= render :partial => "coverages" if !@base_coverages.blank? %>

Good idea. I'd change a bit:

<%= render :partial => "coverages" unless @base_coverages.blank? %>

Regards, Rimantas