Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email validation not showing correct message #20

Open
jeremylynch opened this issue Jun 20, 2017 · 6 comments
Open

Email validation not showing correct message #20

jeremylynch opened this issue Jun 20, 2017 · 6 comments

Comments

@jeremylynch
Copy link
Contributor

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"

@swrobel
Copy link
Contributor

swrobel commented Feb 28, 2018

@allenwq to clarify, when doing the following:

user.update(email: 'new@com.com')
user.errors.full_messages.first
=> "Email is invalid"

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

email.update(email: 'new@com.com')
email.errors.full_messages.first
=> "Email has already been taken"

@allenwq
Copy link
Owner

allenwq commented Apr 5, 2018

@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.

@swrobel
Copy link
Contributor

swrobel commented Apr 17, 2018

@allenwq @ArthurWD does this do anything to fix this issue? #24

@ArthurWD
Copy link
Contributor

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

I get this result:

user.update(email: 'new@com.com')
user.errors.full_messages.first
=> "Email has already been taken"

@allenwq
Copy link
Owner

allenwq commented Apr 18, 2018

@ArthurWD wow, I didn't expect that.

@jeremylynch Can verify if this is still an issue?

@swrobel
Copy link
Contributor

swrobel commented Apr 25, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants