How to display data in grid format?

Hi all,

I have a problem that i want to print data in grid (table format)

following is my partial file named “_coupon.haml.html”
-coupon_template.each do |template_data|
-coupon.initializeFromTemplate(template_data)
#div{:style=>“border: solid; border-color: gray; width: 310px;”}
=haml_engine =
Haml::Engine.new(CouponTemplate.find(coupon.template_id).data).render(Object.new,
:coupon => coupon)
%input{:type=>‘radio’, :name=>‘coupon_template_id’, :value=>
template_data.id}
%br
%br
%br
%br
%hr
%table{:width => “100%”}
%tr
%td{:align => “right”}
=link_to “Cancel”, polymorphic_path(coupon.business)
= submit_tag ‘Next Step’

Currently i am printing coupons one after one.
I want it like following


coupon 1 | coupon 2 | coupon 3 |
| | |
-------------------|------------------|------------------|
coupon 4 | coupon 5 | coupon 6 |
| | |
-------------------|------------------|------------------|

I tried but there is no for loop such that

for i=0, i<coupons.length, i+=3

Thanks,
Vikas

Look at the AR docs for @collection.in_groups_of if you want to process
the coupons in groups of 3.

Ar Chron wrote:

Look at the AR docs for @collection.in_groups_of if you want to process
the coupons in groups of 3.

@collection.in_groups_of is very helpful

Thanks,
Vikas