2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2008-04-25 18:23:48 -04:00
|
|
|
class Reference < ActiveRecord::Base
|
|
|
|
belongs_to :person
|
|
|
|
belongs_to :job
|
2010-10-31 07:21:28 -04:00
|
|
|
|
2017-07-20 23:26:09 -04:00
|
|
|
has_many :ideal_jobs, class_name: "Job", foreign_key: :ideal_reference_id
|
2016-08-06 13:37:57 -04:00
|
|
|
has_many :agents_posts_authors, through: :person
|
2011-03-02 16:24:56 -05:00
|
|
|
|
2012-11-19 09:52:09 -05:00
|
|
|
class << self; attr_accessor :make_comments; end
|
|
|
|
self.make_comments = false
|
2011-02-01 17:56:04 -05:00
|
|
|
|
|
|
|
before_destroy :make_comments
|
|
|
|
|
|
|
|
def make_comments
|
|
|
|
if self.class.make_comments
|
2013-01-02 11:46:58 -05:00
|
|
|
person.update comments: "Reference destroyed"
|
2011-02-01 17:56:04 -05:00
|
|
|
end
|
|
|
|
end
|
2008-04-25 18:23:48 -04:00
|
|
|
end
|
2010-07-19 21:26:57 -04:00
|
|
|
|
|
|
|
class BadReference < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "references"
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope { where(favourite: false) }
|
2010-07-19 21:26:57 -04:00
|
|
|
end
|