Duplicate email addresses

1,316 views
Skip to first unread message

paulo

unread,
Oct 4, 2010, 10:23:52 AM10/4/10
to Devise
Hi all,

I'm implementing a system which requires logins through usernames,
rather than e-mail addresses. I have updated
config.authentication_keys to use the username field, which has been
added successfully to my model, and logins work.

User accounts still need an email field, but accounts may share the
same e-mail address, which is causing problems, as rails/devise is
expecting a unique email address when adding new users.

There is nothing in my model which is enforcing the uniqueness of the
email field, and I've updated my db to remove and indexes which may
have been adding the constraint, but this hasn't made a difference so
far.

When adding a duplicate through the rails console, the command fails
with the error:
'#<OrderedHash {:email=>["has already been taken"]}'

Has anyone else had this problem or have any ideas where the
constraint is being enforced? (I am presuming somewhere in devise?)?


Much appreciated,


Paul Taylor

Carlos Antonio da Silva

unread,
Oct 5, 2010, 7:16:14 PM10/5/10
to plataforma...@googlegroups.com
Are you using :validatable module? If so, you'd have to remove it and add validations by your own.
Take a look here to see what validations are added to your model by this module:

--
At.
Carlos A. da Silva

paulo

unread,
Oct 6, 2010, 9:58:03 AM10/6/10
to Devise
Great, yep its just that simple, have taken it out and its now
allowing them.

I will just move those validations into my user model with the
exception of the validate_unqiueness for email line.

Thanks again,

Paulo

On 6 Oct, 00:16, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> Are you using :validatable module? If so, you'd have to remove it and add
> validations by your own.
> Take a look here to see what validations are added to your model by this
> module:
>
> http://github.com/plataformatec/devise/blob/v1.1/lib/devise/models/va...
Reply all
Reply to author
Forward
0 new messages