Class: User

Inherits:
ApplicationRecord show all
Defined in:
app/models/user.rb

Overview

Represent the user and interface with Devise to log into the application.

Schema Information

Table name: users

Indexes

index_users_on_confirmation_token    (confirmation_token) UNIQUE
index_users_on_email                 (email) UNIQUE
index_users_on_reset_password_token  (reset_password_token) UNIQUE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

policy_class

Instance Attribute Details

#adminBoolean

Returns:

  • (Boolean)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#banned_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#confirmation_sent_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#confirmation_tokenString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#confirmed_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#created_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#emailString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#encrypted_passwordString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#idObject

Returns [].

Returns:


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#remember_created_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#reset_password_sent_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#reset_password_tokenString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#unconfirmed_emailString

Returns:

  • (String)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

#updated_atTime

Returns:

  • (Time)

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/user.rb', line 43

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :confirmable, :database_authenticatable,
         :recoverable, :registerable,
         :rememberable, :validatable
  validates :email, uniqueness: true

  def ban!
    raise 'User has already been Banned' if banned?
    update!(banned_at: Time.zone.now)
  end

  def banned?
    banned_at.present?
  end

  def active_for_authentication?
    super && !banned?
  end
end

Instance Method Details

#active_for_authentication?Boolean

Returns:

  • (Boolean)

60
61
62
# File 'app/models/user.rb', line 60

def active_for_authentication?
  super && !banned?
end

#ban!Object


51
52
53
54
# File 'app/models/user.rb', line 51

def ban!
  raise 'User has already been Banned' if banned?
  update!(banned_at: Time.zone.now)
end

#banned?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'app/models/user.rb', line 56

def banned?
  banned_at.present?
end