0
0
Fork 0

Improve allowed language handling (#2897)

* Dont allow empty value in user allowed languages

* Sanitize language input to reject blank values in array
This commit is contained in:
Matt Jankowski 2017-05-07 21:32:52 -04:00 committed by Eugen Rochko
parent 0291b73de7
commit bba537a7be
4 changed files with 27 additions and 1 deletions

View file

@ -52,6 +52,8 @@ class User < ApplicationRecord
scope :admins, -> { where(admin: true) }
scope :confirmed, -> { where.not(confirmed_at: nil) }
before_validation :sanitize_languages
def confirmed?
confirmed_at.present?
end
@ -77,4 +79,10 @@ class User < ApplicationRecord
def setting_auto_play_gif
settings.auto_play_gif
end
private
def sanitize_languages
allowed_languages.reject!(&:blank?)
end
end