devise-multi_email icon indicating copy to clipboard operation
devise-multi_email copied to clipboard

Email validation not showing correct message

Open jeremylynch opened this issue 7 years ago • 6 comments

Email validation always returns Email is invalid even when the email "has already been taken" (uniqueness validation).

Email validation should show "has already been taken"

jeremylynch avatar Jun 20 '17 04:06 jeremylynch

@allenwq to clarify, when doing the following:

user.update(email: '[email protected]')
user.errors.full_messages.first
=> "Email is invalid"

But when updating the email directly, you get the following:

email.update(email: '[email protected]')
email.errors.full_messages.first
=> "Email has already been taken"

swrobel avatar Feb 28 '18 20:02 swrobel

@swrobel Yes, I get it, this is a rails behaviour. we can fix it by propagating the email errors one level up. but i am not sure if we should leave the application to handle it... let me think.

allenwq avatar Apr 05 '18 12:04 allenwq

@allenwq @ArthurWD does this do anything to fix this issue? https://github.com/allenwq/devise-multi_email/pull/24

swrobel avatar Apr 17 '18 15:04 swrobel

Seems to me like this issue is indeed fixed by #24.

I get this result:

user.update(email: '[email protected]')
user.errors.full_messages.first
=> "Email has already been taken"

ArthurWD avatar Apr 18 '18 07:04 ArthurWD

@ArthurWD wow, I didn't expect that.

@jeremylynch Can verify if this is still an issue?

allenwq avatar Apr 18 '18 15:04 allenwq

@ArthurWD that's odd, I can't seem to replicate that behavior. I still get Email is invalid with latest master & Rails 5.2.0

Update: I'm able to get the same behavior that @ArthurWD sees by adding autosave: true to my emails association, ex:

has_many :emails, autosave: true

This doesn't require using the latest w/ ArthurWD's change merged.

swrobel avatar Apr 25 '18 00:04 swrobel