Sha256: 3901d05ba9cfbf3f4dc92bceead5d53c0a671aa0a9bb36cfefa9a8d849977b63

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

# frozen_string_literal: true

class ApplicationController < ActionController::Base
  around_action :set_time_zone

  helper_method :current_time_zone

  private

  def set_time_zone(&block)
    Time.use_zone(current_time_zone, &block)
  end

  def current_time_zone
    @current_time_zone ||=
      if session[:current_time_zone].present?
        ActiveSupport::TimeZone[session[:current_time_zone]] || ActiveSupport::TimeZone["UTC"]
      else
        ActiveSupport::TimeZone["UTC"]
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
script_core-0.1.0 spec/dummy/app/controllers/application_controller.rb