aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-23 23:55:59 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-23 23:55:59 +0000
commit65d3430baf759c1b31cca4dde51b770804d8efbb (patch)
treeb96b72e6ab4939eb0d6faff67d5bfabd5fc5fbfe /actionpack/lib
parent11a2bb91f5153ab408ba7bd7a58948334729997b (diff)
downloadrails-65d3430baf759c1b31cca4dde51b770804d8efbb.tar.gz
rails-65d3430baf759c1b31cca4dde51b770804d8efbb.tar.bz2
rails-65d3430baf759c1b31cca4dde51b770804d8efbb.zip
Fixed TimeZone issues in action-pack and active-support #704
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@776 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 8ead838d36..aeef3bba74 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -185,6 +185,9 @@ module ActionView
# (long) list. (You can use TimeZone.us_zones as a convenience for
# obtaining a list of the US time zones.)
#
+ # The +selected+ parameter must be either +nil+, or a string that names
+ # a TimeZone.
+ #
# By default, +model+ is the TimeZone constant (which can be obtained
# in ActiveRecord as a value object). The only requirement is that the
# +model+ parameter be an object that responds to #all, and returns
@@ -195,16 +198,17 @@ module ActionView
def time_zone_options_for_select(selected = nil, priority_zones = nil, model = TimeZone)
zone_options = ""
+ zones = model.all
+ convert_zones = lambda { |list| list.map { |z| [ z.to_s, z.name ] } }
+
if priority_zones
- zone_options += options_for_select(priority_zones, selected)
+ zone_options += options_for_select(convert_zones[priority_zones], selected)
zone_options += "<option>-------------</option>\n"
- zones = model.all.reject { |z| priority_zones.include?( z ) }
- zone_options += options_for_select(zones, selected)
- else
- zone_options += options_for_select(model.all, selected)
+ zones = zones.reject { |z| priority_zones.include?( z ) }
end
+ zone_options += options_for_select(convert_zones[zones], selected)
zone_options
end
@@ -292,4 +296,4 @@ module ActionView
end
end
end
-end \ No newline at end of file
+end