rails 動態時區實作
如何依照不同的條件,例如登入的使用者,來調整預設時區

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
延伸閱讀
加入 BNI 商會心得
於 2023/10 加入了 BNI 台南商會(大信白金),本篇文章將分享加入後的心得,並持續更新心得內容,確認在不同階段的自己是否有偏離初衷。
rails app(web) 嵌入到 iframe 中
ruby on rails 的 web 預設是無法嵌入到 HTML iframe 中的,本篇文章將教學如何使其成功在不同網域中將 rails web 成功嵌入到 iframe 中。
設定電子郵件 DMARC
提供設定 DMARC 的範例,並且提供官方語法說明和檢測工具連結。

