class User

User model used to represent registered User

Public Instance Methods

active_for_authentication?() click to toggle source
devise

ensure user account is active

Calls superclass method
# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 35
def active_for_authentication?
  super && !deleted_at?
end
first_name() click to toggle source

Short display name for user

# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 16
def first_name
  namae.given
end
image() click to toggle source

Display image for user

# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 21
def image
  return unless email?

  require "digest/md5"
  hash = Digest::MD5.hexdigest(email.downcase)
  "https://s.gravatar.com/avatar/#{hash}?s=480"
end
inactive_message() click to toggle source
devise

provide a custom message for a soft-deleted account

Calls superclass method
# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 40
def inactive_message
  !deleted_at? ? super : :deleted_account
end
soft_delete() click to toggle source

instead of deleting users, mark them as soft deleted

# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 30
def soft_delete
  update_attribute(:deleted_at, Time.current)
end
to_s() click to toggle source
Calls superclass method
# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 44
def to_s
  # Use the stored name value for labels
  (name_changed? ? name_was : name) || super
end

Private Instance Methods

namae() click to toggle source
# File lib/generators/rockstart/authorization/devise/templates/models/user.rb, line 51
def namae
  @namae ||= Namae::Name.parse(name)
end