2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
require "models/job"
|
2016-07-09 22:42:51 -04:00
|
|
|
|
2014-12-28 17:24:10 -05:00
|
|
|
class User < ActiveRecord::Base
|
|
|
|
has_secure_token
|
2019-04-09 15:40:16 -04:00
|
|
|
has_secure_token :auth_token, length: 36
|
2016-07-09 22:42:51 -04:00
|
|
|
|
|
|
|
has_and_belongs_to_many :jobs_pool,
|
2017-01-03 10:12:47 -05:00
|
|
|
class_name: "Job",
|
2016-08-06 12:26:20 -04:00
|
|
|
join_table: "jobs_pool"
|
2017-01-28 15:43:45 -05:00
|
|
|
|
|
|
|
has_one :family_tree, -> { where(token: nil) }, foreign_key: "member_id"
|
|
|
|
has_one :family, through: :family_tree
|
|
|
|
has_many :family_members, through: :family, source: :members
|
2014-12-28 17:24:10 -05:00
|
|
|
end
|
2015-02-18 17:55:48 -05:00
|
|
|
|
|
|
|
class UserWithNotification < User
|
|
|
|
after_create -> { Notification.create! message: "A new user has been created." }
|
|
|
|
end
|