I'm using authlogic with my user model, with the login field set to use email, thus:
acts_as_authentic do |c|
c.login_field = :email
end
If i try to make 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'm guessing this is something to do with using the email as the login, maybe? I don't have any other validations on email apart from validates_format_of, and i experimented with removing that validation (doesn't make any difference).
It's a pain as it's messing up my the errors i show on the form when validation fails.
Before i go trying to hack authlogic, does anyone know why this might be happening? thanks, max
I just ran into the same issue. Try calling config.validate_email_field = false
in the acts_as_authentic
block. It'll still validate the login field, which in our case in the email field, but only once.
acts_as_authentic do |config|
config.login_field :email
config.validate_email_field = false
...
end
There are two methods in Authlogic: validate_email_field and validate_login_field.
These methods disable/enable the specific validations:
I also use config.login_field :email
in my app, and I need to be sure that User#email
is validated. So in my case I chose to use config.validate_login_field = false
because of the difference between the validations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With