Re: [Rails] Collect value

2013-01-21 Thread Jordon Bedwell
On Mon, Jan 21, 2013 at 11:21 AM, Rob Biedenharn wrote: > I tend to use a method like: > > module Enumerable > # Returns a Hash keyed by the value of the block to the number times that > # value was returned. If you have experience with the #group_by from > # ActiveSupport, this would be li

Re: [Rails] Collect value

2013-01-21 Thread Rob Biedenharn
I tend to use a method like: module Enumerable # Returns a Hash keyed by the value of the block to the number times that # value was returned. If you have experience with the #group_by from # ActiveSupport, this would be like .group_by(&block).map{|k,a|[k,a.size]} # (except it is a Hash r

Re: [Rails] Collect value

2013-01-20 Thread Ashokkumar Yuvarajan
thanks :) On Mon, Jan 21, 2013 at 12:06 PM, bala kishore pulicherla < balumc...@gmail.com> wrote: > a.count("casual") -- *"Attitude is a little thing that makes a big difference"* Thanks & Regards *Ashokkumar.Y* *ROR-Developer **email : ashokku...@shriramits.com* *Shriramits* * * -- Y

Re: [Rails] Collect value

2013-01-20 Thread bala kishore pulicherla
we can use a.count("casual") and viceversa. On Mon, Jan 21, 2013 at 12:03 PM, Maddy wrote: > Hi Everyone, > > Good Day, > > a=[ 'casual','sick','casual','sick','casual','sick','casual','sick' ] > > I need to collect casual's count and sick's count like, > Caual :4 > Sick :4 > > Thank you, > > -

[Rails] Collect value

2013-01-20 Thread Maddy
Hi Everyone, Good Day, a=[ 'casual','sick','casual','sick','casual','sick','casual','sick' ] I need to collect casual's count and sick's count like, Caual :4 Sick :4 Thank you, -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post