From: Seth Thomas Rasmussen Date: 2006-03-04T05:58:40+09:00 Subject: Re: cleaner Ruby in a rails view Hi all, Interesting discussion... I'll just add that the following: > <% item.cart_item_option_values.each do |ov| %> Can be: <%= render :partial => 'foo', :collection => item.cart_item_option_values %> _foo.rhtml would contain the markup used to render each item in the collection. Sometimes I also like to do this, however: <%= render :partial => 'foos', :object => some_collection %> And then in _foos.rhtml have logic like: <% if foos -%> <% end -%> In the latter example, you also might want to forego the collection rendering capability and use ERb tags to do an each() block, simple because too many levels of partials becomes cumbersome. Either way, it's generally more pleasing (if not outright useful, say, for less savvy designers) to remove more complicated logic from the 'root level' view templates. The reason being, I think, because once you get to a certain point, you're logic is solid, but you're markup structure and flow might demand tweaking.