How can i prefill datetime_select with times in custom time zone?

后端 未结 1 1856
情话喂你
情话喂你 2021-01-14 11:05

I have events that can be in different time zones.

Upon edit I want the time & date to show with the time zone

相关标签:
1条回答
  • 2021-01-14 11:35

    As pixeltrix pointed out in the thread of the bug report, it's cleaner to override the readers/getters of the attributes in question like so:

    # in event model
    
    def beginn
      super.in_time_zone(time_zone) if super
    end
    
    def endd
        super.in_time_zone(time_zone) if super
    end
    

    This way the logic in the edit action as outlined in the question can be omitted and interferences with other parts that rely on Time.zone are avoided.

    0 讨论(0)
提交回复
热议问题