rails 的 ActiveSupport 有提供 Time 的擴充 method: use_zone ,利用 code block 機制即可實作。

Time.use_zone('Taipei') { Time.current }

如此便可利用 controller 的 around_action 來確保所有或部分的 action 內的預設時區

class ApplicationController
  around_action :set_current_user_timezone!, if: :user_signed_in?

  private
  
  def set_current_user_timezone!(&block)
    Time.user_zone(current_user.timezone, &block)
  end
end