From: Sijo Kg Date: 2009-03-25T19:42:07+09:00 Subject: creating an array by reusing code Hi I have all_req = OnRequest.find(:all, :conditions => [status_id = ?',6]) Now i need to create an array of size 12 containing record counts for month January to December like [recordcountjanuary,recordcountfeb,....] So for the first month january I tried like all_req.select do |r| r.created_at.mon == 1 end What i need is reuse the above code I have placed it in a function But there I have to call it 12 times .How can i avoid this? Thanks in advance Sijo -- Posted via http://www.ruby-forum.com/.