Sha256: 6b09e3fe2ef6195701e50a2a5e79e86bbd89f0fd263ba5f29e1a8e53a6d432c8

Contents?: true

Size: 755 Bytes

Versions: 7

Compression:

Stored size: 755 Bytes

Contents

class Character::User
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Attributes::Dynamic # required to remove users using _delete field

  field     :email
  validates :email,
            presence:   true,
            uniqueness: true#,
            #format:     { :with => /^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i }

  index({ email: 1 }, { unique: true })

  # Methods -----------------------------------------------

  def self.find_by_email(email)
    where(email:email).first()
  end

  def gravatar_url(size)
    hash = Digest::MD5.hexdigest(email)
    # http://robohash.org
    "https://robohash.org/bgset_bg2/#{hash}?gravatar=hashed&size=#{size}x#{size}"
  end

  def chr_thumbnail_url
    gravatar_url(56)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
character-1.0.6 app/models/character/user.rb
character-1.0.5 app/models/character/user.rb
character-1.0.4 app/models/character/user.rb
character-1.0.3 app/models/character/user.rb
character-1.0.2 app/models/character/user.rb
character-1.0.1 app/models/character/user.rb
character-1.0.0 app/models/character/user.rb