How to use datetime_select to edit an existing model record, that takes in account for time zones?

I am trying to write a simple calendar app and having troubles with time
zones. For as many nice Date and Time helpers, action view and active
record sure don’t play nice with time zones.

I have an appointment model with the appointment_time attribute which is
a
datetime.

My current issue is editing appointment_time with datetime_select within
a
form tag.

<%= datetime_select :appointment_time, @appt.appt_time,ampm: true %>

def appt_time
appointment_time.in_time_zone(time_zone) #this is the appointment
owners time zone
end

This gives a select with the current date and time in UTC, not the
appointment date and time. appt_time does get called and returns the
correct date and time adjusted for the time zone.

The docs mention nothing about time zones, what is the best way to
accomplish this?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs