Sha256: 268afcf4630b308b6be87d4eb3d31eaa06456acc7b26ed4cddbb2e2a403196ad

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

class UserEmail

  include Model

  field :email, type: String
  field :confirmed, type: Boolean
  field :confirmation_token, type: String

  embedded_in :user

  # validates uniqueness of email among all users
  validate do |record|
    if User.elem_match( :emails => { :email => record.email, :_id.ne => record.id } ).count > 0
      record.errors.add :email, :unique
    end
  end

  # Returns Authentication associated with email, if any
  #
  # def authentication
  #  user.authentications.where( email_id: self.id )
  # end

end # class UserEmail

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aerogel-users-1.4.3 db/model/user_email.rb