Module: CalendarizeHelper::Controller

Defined in:
app/helpers/calendarize_helper.rb

Overview

Methods used in an existing controller to get the params associated to a calendar and pass them to the view Automatically included by the engine as a class helper Right now it only supports one calendar per view but it should not be hard to throw some :uuid in the process

Usage:

class MyCalendarController < ApplicationController

calendarize

end

Instance Method Summary collapse

Instance Method Details

#calendarizeObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/helpers/calendarize_helper.rb', line 91

def calendarize

  before_filter lambda {
    @calendar = { }

    # I hate time handling in RoR...
    # Time.zone.parse is prefered to DateTime.parse because it preserve the timezone

    if params[:calendar]
      @calendar[:date] = Time.zone.parse(params[:calendar][:date]).to_datetime
      @calendar[:verbose] = params[:calendar][:verbose] == 'true'
      @calendar[:scope] = params[:calendar][:scope]
    else
      @calendar[:date] = DateTime.now.beginning_of_day
      @calendar[:verbose] = true
      @calendar[:scope] = 'daily'
    end
  }

end