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_time_zones, (record ? record.send(attribute.to_sym) : nil))) end |
#grouped_time_zones ⇒ Object
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 = lambda do |zones| zones.map { |tz| [tz.to_s, tz.tzinfo.identifier] } end return [['United States', .call(us_zones)], ['Other', .call(other_zones)]] end |