class HomeController < ApplicationController def index current_year = (params[:year ] || Date.today.year ) current_month = (params[:month] || Date.today.month) @current_date = "#{current_year}-#{current_month}-#{Date.today.day}".to_date @days_in_month = [] @days_in_month[@current_date.beginning_of_month.wday] = (@current_date.beginning_of_month..@current_date.end_of_month).to_a @days_in_month = @days_in_month.flatten.in_groups_of(7, false) @beginning_of_month_blanks_count = @current_date.beginning_of_month.wday @days_in_month[0].compact! @end_of_month_blanks_count = (6 - @current_date.end_of_month.wday) puts @days_in_month.inspect end end