Working with in_groups_of

I’m trying to build a table out using in groups of, but I’d also like to
be able to customize the first and last rows.

Apart from the actual formatting, is there an efficient way to figure
out how many total groups there are and what group the iteration is in?

On Sun, Mar 8, 2009 at 4:57 PM, Rob Scott
[email protected] wrote:

I’m trying to build a table out using in groups of, but I’d also like to
be able to customize the first and last rows.

Apart from the actual formatting, is there an efficient way to figure
out how many total groups there are and what group the iteration is in?

users = User.find(:all).in_groups_of( 3 )

users.first and users.last will be the first and last groups
respectively.

users.size will be the total groups of users.

And then going forward you can figure all this out on your own using
users.methods.sort… like seeing that users.class is an Array will let
you know you can use anything from the Array class on your users
collection.


Greg D.
http://destiney.com/