Created
January 22, 2014 21:53
-
-
Save anamartinez/8568103 to your computer and use it in GitHub Desktop.
Time zone select rails helper with formatted offset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= f.time_zone_select :time_zone, TimeZoneWithFormattedOffset.all.sort_by { |tz| [tz.now.utc_offset, tz.name] } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeZoneWithFormattedOffset < ActiveSupport::TimeZone | |
def to_s | |
"(GMT#{self.now.formatted_offset}) #{self.name}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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.