Ruby on Rails Friday, December 4, 2015

I am writing 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) end


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 what should be obvious and built into datetime_select?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7b8d1396-0dd2-40e3-a877-4e4ebf15a41c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment