Sha256: 41402274f2cd2aac2af71197594c4af46a6b9b8f4d0f08267aba9b867e85a8bd
Contents?: true
Size: 589 Bytes
Versions: 4
Compression:
Stored size: 589 Bytes
Contents
class HomeController < ApplicationController def index @months = [] collect_months(@months) append_current_month(@months) end private def collect_months(months) oldest = Item.minimum("date") newest = Item.maximum("date") if oldest and newest m = newest.beginning_of_month while m >= oldest.beginning_of_month months.push m m <<= 1 end end end def append_current_month(months) current = Time.now.to_date.beginning_of_month unless months.include?(current) months.unshift current end end end
Version data entries
4 entries across 4 versions & 1 rubygems