Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10590 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH][DOCS] time_zone_select with default time zone

Reported by: matt Assigned to: core
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: time zone, time_zone, time_zone_select
Cc:

Description

Here is the case scenario:

I want to give my user the option of defining their time zone. Since this feature is optional, a user might or might not have already selected a time zone.

By default, the time_zone_select helper gets the object's time zone and selects it. While that works in most cases, if you have a new object or an object without time zone then you can't have anything pre selected.

A workaround would be to directly use

time_zone_options_for_select

but I think we can do better/cleaner.

This patch adds an optional :default option.

 time_zone_select( "user", 'time_zone', TimeZone.us_zones, :default => "Pacific Time (US & Canada)")

If the user's time_zone value isn't set, the select box will select the default value.

(tests and docs in patch)

Attachments

improved_time_zone_select-default_TZ.diff (3.3 kB) - added by matt on 12/21/07 20:08:09.

Change History

12/21/07 20:08:09 changed by matt

  • attachment improved_time_zone_select-default_TZ.diff added.

12/21/07 21:17:34 changed by dkubb

+1

12/21/07 22:18:10 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [8473]) Add :default option to time_zone_select. Closes #10590.