From 72c4e9f24c99d902db7b6ecbe9aa28176869d619 Mon Sep 17 00:00:00 2001 From: rahul Date: Wed, 26 Jul 2017 22:31:54 +0530 Subject: [PATCH] add valid email regex in user.rb --- app/models/user.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index f3f03ab7..ac8ce37c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -64,7 +64,8 @@ class User < ActiveRecord::Base scope :admin, -> { where(is_admin: true) } scope :active, -> { where(is_disabled: false) } - validates :email, presence: true + VALID_EMAIL_REGEX = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i + validates :email, presence: true, format: {with: VALID_EMAIL_REGEX } validates :username, uniqueness: {