Authlogic: Generates an Email Already Done Error Twice

I use authlogic with my user model, with an input field set to use email, like this:

acts_as_authentic do |c| c.login_field = :email end 

If I try to create a new user and the email is already in use, it adds a duplicate email error twice: (from the console)

 user = User.new(:first_name => "fred", :last_name => "Smith", :email => User.last.email);user.valid?;errors = user.errors => {:email=>["has already been taken", "has already been taken"]} 

I suppose this has something to do with using email as a login, maybe? I have no other email checks other than validates_format_of, and I experimented with deleting this check (it doesn't make any difference).

This is a pain because it ruined my mistakes, which I show on the form when the validation fails.

Before I try to hack authlogic, does anyone know why this could happen? thanks max

+7
source share
2 answers

I just ran into the same problem. Try calling config.validate_email_field = false on the acts_as_authentic block. He will still check the login field, which in our case is in the email field, but only once.

 acts_as_authentic do |config| config.login_field :email config.validate_email_field = false ... end 
+10
source

Authlogic has two methods: validate_email_field and validate_login_field.

These methods disable / activate certain checks:

I also use config.login_field :email in my application, and I need to make sure that User#email checked. So in my case, I decided to use config.validate_login_field = false due to the difference between the checks.

+2
source

All Articles