Module: GroupedTimeZones::ViewHelpers

Defined in:
lib/grouped_time_zones/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#grouped_time_zone_select(name, attribute, record = nil) ⇒ Object



3
4
5
6
# File 'lib/grouped_time_zones/view_helpers.rb', line 3

def  grouped_time_zone_select(name, attribute, record=nil)
  
  select_tag("#{name}[#{attribute}]", grouped_options_for_select(grouped_time_zones, (record ? record.send(attribute.to_sym) : nil)))
end

#grouped_time_zonesObject



8
9
10
11
12
13
14
15
# File 'lib/grouped_time_zones/view_helpers.rb', line 8

def grouped_time_zones
  us_zones = ActiveSupport::TimeZone.us_zones
  other_zones = ActiveSupport::TimeZone.all.sort - us_zones
  zone_options = lambda do |zones|
    zones.map { |tz| [tz.to_s, tz.tzinfo.identifier] }
  end
  return [['United States', zone_options.call(us_zones)], ['Other', zone_options.call(other_zones)]]
end