On Jul 21, 11:08 am, Joachim Cheng <[email protected]> wrote: > Frederick Cheung wrote in post #1012069: > > > On Jul 21, 9:43am, Joachim Cheng <[email protected]> wrote: > >> Hi, I am beginner RoR. I need your advanced programming... > > >> @rollresults = RollResult.where(:banker_id =>'3') > > > So you want to group your results by roll_no ? > > > Fred > > Yes, I want to result group by roll_no. > > @rollresults = RollResult.where(:banker_id =>'3') > @rollresults.each do |p| > if p.roll_no == '512' #<--- Can't work > # group by 3times.. > else > # continues finding roll_no == '512' > end > end >
I don't understand what you mean by 'group by 3 times', but you might want to look at group_by (method on array) or at sql's "group by" clause Fred > Can you teach me...? > > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

