FIX: allow multiple secondary emails

This commit is contained in:
Leo McArdle
2017-12-21 12:30:26 +00:00
committed by Guo Xiang Tan
parent 98478d78d7
commit c3129444ea
3 changed files with 48 additions and 1 deletions

View File

@ -11,7 +11,7 @@ class UserEmail < ActiveRecord::Base
validates :email, email: true, format: { with: EmailValidator.email_regex },
if: :validate_email?
validates :primary, uniqueness: { scope: [:user_id] }, if: :user_id
validates :primary, uniqueness: { scope: [:user_id] }, if: [:user_id, :primary]
validate :user_id_not_changed, if: :primary
validate :unique_email