Skip to content

Instantly share code, notes, and snippets.

@eladmeidar
Created July 31, 2013 11:13
Show Gist options
  • Save eladmeidar/6121183 to your computer and use it in GitHub Desktop.
Save eladmeidar/6121183 to your computer and use it in GitHub Desktop.
User specific timezones in rails
<%= f.label :time_zone %>
<%= f.time_zone_select :time_zone %>
class AddTimezoneColumnToUsers < ActiveRecord::Migration
def self.change
add_column :users, :time_zone, :string
end
end
class ApplicationController < ActionController::Base
before_filter: set_user_time_zone
def set_user_time_zone
Time.zone = current_user.time_zone if user_signed_in?
end
end
@sbimochan
Copy link

expired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment