diff options
author | Azul <azul@leap.se> | 2012-12-13 11:49:26 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-12-13 11:49:55 +0100 |
commit | d7890d7c8af6691df2817a9b6654acf9377847bd (patch) | |
tree | c66372f4d25a34028b8873fb652761e8f4a1ec02 /users/app/models/local_email.rb | |
parent | 60e8fc3e1309d1c972a7695e3344e63f5d633a06 (diff) |
LocalEmail added - will validate uniqueness amongst emails and aliases
Diffstat (limited to 'users/app/models/local_email.rb')
-rw-r--r-- | users/app/models/local_email.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/users/app/models/local_email.rb b/users/app/models/local_email.rb new file mode 100644 index 0000000..5762a33 --- /dev/null +++ b/users/app/models/local_email.rb @@ -0,0 +1,11 @@ +class LocalEmail < Email + + validate :unique_on_server + + def unique_on_server + has_email = User.find_by_email_or_alias(email) + if has_email && has_email != self.base_doc + errors.add(:email, "has already been taken") + end + end +end |