aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/models/reference.rb
blob: 2a7a1e3b77512cac745a98e0c8fff23f5f6152f9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                             


                                    
 
                                                  
 

                                                  




                               
                                                   

       
   

                                       
                                
                                           
   
# frozen_string_literal: true

class Reference < ActiveRecord::Base
  belongs_to :person
  belongs_to :job

  has_many :agents_posts_authors, through: :person

  class << self; attr_accessor :make_comments; end
  self.make_comments = false

  before_destroy :make_comments

  def make_comments
    if self.class.make_comments
      person.update comments: "Reference destroyed"
    end
  end
end

class BadReference < ActiveRecord::Base
  self.table_name = "references"
  default_scope { where(favourite: false) }
end