time_zone未保存在数据库中

时间:2011-11-11 10:34:12

标签: ruby-on-rails timezone

我让用户根据下拉时间从下拉列表中选择时区。

使用rails 2.3.9和ruby 1.8.7 我的代码是这样完成的  在应用程序控制器中

before_filter:set_time_zone   def set_time_zone     Time.zone = current_user.time_zone if current_user   端

视图中的

(haml) f.time_zone_select:time_zone,ActiveSupport :: TimeZone.all.sort

用户表中的

将time_zone添加为字符串

在environment.rb中 config.gem ='UTC'

但是虽然下降时间与时区一起出现......但它没有得到保存。

1 个答案:

答案 0 :(得分:0)

environment.rb中的行应该看起来像

config.time_zone = 'UTC'

您的表单应如下所示:

<%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones %>
相关问题