Skip to content
Snippets Groups Projects
user.rb 1.74 KiB
Newer Older
Arnaud Levy's avatar
Arnaud Levy committed
# == Schema Information
#
# Table name: users
#
#  id                     :uuid             not null, primary key
#  confirmation_sent_at   :datetime
#  confirmation_token     :string
#  confirmed_at           :datetime
#  current_sign_in_at     :datetime
#  current_sign_in_ip     :string
#  email                  :string           default(""), not null
#  encrypted_password     :string           default(""), not null
#  failed_attempts        :integer          default(0), not null
#  first_name             :string
#  last_name              :string
#  last_sign_in_at        :datetime
#  last_sign_in_ip        :string
#  locked_at              :datetime
#  remember_created_at    :datetime
#  reset_password_sent_at :datetime
#  reset_password_token   :string
#  role                   :integer
#  sign_in_count          :integer          default(0), not null
#  unconfirmed_email      :string
#  unlock_token           :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#  university_id          :uuid             not null
Arnaud Levy's avatar
Arnaud Levy committed
#
# Indexes
#
#  index_users_on_confirmation_token       (confirmation_token) UNIQUE
#  index_users_on_email_and_university_id  (email,university_id) UNIQUE
#  index_users_on_reset_password_token     (reset_password_token) UNIQUE
#  index_users_on_university_id            (university_id)
#  index_users_on_unlock_token             (unlock_token) UNIQUE
#
# Foreign Keys
#
#  fk_rails_...  (university_id => universities.id)
Arnaud Levy's avatar
Arnaud Levy committed
#
class User < ApplicationRecord
  include WithDevise

  belongs_to :university
Arnaud Levy's avatar
Arnaud Levy committed
  has_one :researcher, class_name: 'Research::Researcher'
Arnaud Levy's avatar
Arnaud Levy committed

  def to_s
    first_name || last_name ? "#{first_name} #{last_name}"
                            : "#{email}"
  end
end