#106 Time Zones in Rails 2.1

In the past, time zones have been very difficult to work with, but no longer! Rails 2.1 brings with it great time zone support as you can see in this episode.

rake time:zones:local

# config/environment.rb
config.time_zone = "Pacific Time (US & Canada)"

# controllers/application.rb
before_filter :set_user_time_zone

private

def set_user_time_zone
  Time.zone = current_user.time_zone if logged_in?
end

# in migration file
add_column :users, :time_zone, :string

<!-- users/new.html.erb -->
<%= f.time_zone_select :time_zone, TimeZone.us_zones %>

你可能感兴趣的:(html,F#,Rails)