On Thu, 2 Mar 2006 petermichaux / yahoo.com wrote:

> Hi,
>
> I think this is a pure Ruby question. I seem to be writing this nested
> structure constantly
>
> <% unless item.cart_item_optional_variations.empty? %>
>  <% item.cart_item_option_values.each do |ov| %>
>
>  <% end %>
> <% end %>
>
> Is there a way to write this in one steps so i am not doing nil.each?
>
> Thanks,
> Peter
>
>

just return an empty array when 'cart_item_option_values' is nil

   <% (item.cart_item_option_values || []).each do |ov| %>

regards.

-a

-- 
judge your success by what you had to give up in order to get it.
- h.h. the 14th dali lama