Created
July 31, 2013 11:13
-
-
Save eladmeidar/6121183 to your computer and use it in GitHub Desktop.
User specific timezones in rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= f.label :time_zone %> | |
<%= f.time_zone_select :time_zone %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddTimezoneColumnToUsers < ActiveRecord::Migration | |
def self.change | |
add_column :users, :time_zone, :string | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
expired