Skip to content

Commit

Permalink
Fix issue with blank timezone
Browse files Browse the repository at this point in the history
The time zone was not supposed to be blank. This commit fixes that wrong
behaviour.

Fix: #54
  • Loading branch information
tagliala committed Mar 17, 2017
1 parent 3f93635 commit 1cf56ed
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
before_action :check_banned, except: [:banned], if: :user_signed_in?

around_action :localize_route
around_action :time_zone_from_user, if: :user_signed_in?
around_action :time_zone_from_user, if: -> { user_signed_in? && current_user.time_zone? }

private

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class User
field :banned, type: Boolean, default: false

validates :gender, inclusion: GENDER, allow_blank: true
validates :time_zone, inclusion: ActiveSupport::TimeZone.all.map(&:name), allow_blank: true
validates :time_zone, inclusion: ActiveSupport::TimeZone.all.map(&:name)
validates :vehicle_avg_consumption, numericality: { greater_than: 0, less_than: 10 }, presence: true

def age
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/settings.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
fieldset
legend= t('.application_settings')
= f.input :locale, collection: I18n.available_locales.map { |locale| [t('lang_native_name', locale: locale), locale] }, disabled: I18n.available_locales.one?, wrapper: :horizontal_form
= f.input :time_zone, wrapper: :horizontal_form
= f.input :time_zone, wrapper: :horizontal_form, include_blank: false
.form-group
.col-sm-10.col-sm-offset-2
= label_tag :notification_group, t('.send_email'), class: 'control-label'
Expand Down

0 comments on commit 1cf56ed

Please sign in to comment.