From: Christian Neukirchen Date: 2006-03-02T20:38:06+09:00 Subject: Re: cleaner Ruby in a rails view petermichaux@yahoo.com writes: > 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? How about this: <% item.cart_item_option_values.to_a.each do |ov| %> <% end %> # nil.to_a == [] > Thanks, > Peter -- Christian Neukirchen http://chneukirchen.org