Module: TimeZoneConcern

Extended by:
ActiveSupport::Concern
Included in:
Course, User
Defined in:
app/models/concerns/time_zone_concern.rb

Instance Method Summary collapse

Instance Method Details

#time_zoneString

Override ActiveRecord's default time_zone getter method.

If time_zone for model is not set, default it to Application Default. If time_zone for model is set and invalid, default to Application Default. If time_zone for model is set and valid, return model set time_zone.

Returns:

  • (String)

    time_zone to be applied on model.


16
17
18
19
20
21
22
# File 'app/models/concerns/time_zone_concern.rb', line 16

def time_zone
  if self[:time_zone] && ActiveSupport::TimeZone[self[:time_zone]].present?
    self[:time_zone]
  else
    Application.config.x.default_user_time_zone
  end
end