Skip to content

Instantly share code, notes, and snippets.

@anamartinez
Created January 22, 2014 21:53
Show Gist options
  • Save anamartinez/8568103 to your computer and use it in GitHub Desktop.
Save anamartinez/8568103 to your computer and use it in GitHub Desktop.
Time zone select rails helper with formatted offset
<%= f.time_zone_select :time_zone, TimeZoneWithFormattedOffset.all.sort_by { |tz| [tz.now.utc_offset, tz.name] } %>
class TimeZoneWithFormattedOffset < ActiveSupport::TimeZone
def to_s
"(GMT#{self.now.formatted_offset}) #{self.name}"
end
end
@msumit
Copy link

msumit commented Dec 20, 2018

@dduqueti, thanks a ton man, spent hours in debugging the same issue and wasn't able to figure out why the @lazy_zones_map is empty and throwing errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment