Skip to content

Commit

Permalink
thread safe time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaronixon committed Jul 15, 2023
1 parent a7d538a commit 5eed0c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class Admin::BaseController < ActionController::Base
include Pagy::Backend

before_action :set_time_zone
around_action :set_time_zone
before_action :authenticate

private
def set_time_zone
Time.zone = cookies[:time_zone]
Time.use_zone(cookies[:time_zone]) { yield }
end

def authenticate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Admin::Current < ActiveSupport::CurrentAttributes
attribute :user; resets { Time.zone = nil }
attribute :user
end

0 comments on commit 5eed0c8

Please sign in to comment.