当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - 'GMT-05:00) EST' option unexpectedly included in time_zone_select dropdown

问题描述:

(With Rails 3.2.20, ruby 1.9.3)

In my website in production the '(GMT-05:00) EST' option is unexpectedly included in the time_zone_select dropdown:

This timezone does not exists in ActiveSupport::TimeZone::MAPPING. It is injected ActiveSupport::TimeZone.zones_map:

def zones_map

@zones_map ||= begin

new_zones_names = MAPPING.keys - lazy_zones_map.keys

new_zones = Hash[new_zones_names.map { |place| [place, create(place)] }]

lazy_zones_map.merge(new_zones)

end

end

on the line lazy_zones_map.merge(new_zones) because lazy_zones_map contains the "EST" zone.

It does not happen on my development box and does not happen in my Rails production console: ActiveSupport::TimeZone.send :lazy_zones_map returns {"UTC"=>(GMT+00:00) UTC}.

But when I put in my view in production

<%= ActiveSupport::TimeZone.send :lazy_zones_map %>

I get {"UTC"=>(GMT+00:00) UTC, "EST"=>(GMT-05:00) EST}. I don't understand why it happens, any idea?

The #lazy_zones_map definition is

def lazy_zones_map

require_tzinfo

@lazy_zones_map ||= Hash.new do |hash, place|

hash[place] = create(place) if MAPPING.has_key?(place)

end

end

EDIT: the same version of tzinfo is used in production and development, 0.3.44 (I've checked with the command Gem.loaded_specs["tzinfo"]).

分享给朋友:
您可能感兴趣的文章:
随机阅读: