Rails + strefy czasowe
Domyślna strefa czasowa:
config/application.rb
config.time_zone = 'Warsaw'
Preferencje użytkowników:
Dodaj pole timezone do modelu.
walidacja w modelu
validates :timezone, :inclusion => { :in => ActiveSupport::TimeZone.all.map(&:name) }
widok
<%= label_tag t('users.form.timezone') %> <br/> <%= time_zone_select(:user, :timezone) %>
app/controllers/application_controller.rb
before_filter :set_user_time_zone protected def set_user_time_zone Time.zone = current_user.timezone if logged_in? end
Brak Komentarzy »
Subskrybuj komentarze tego wpisu