aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/reference.rb
blob: 76c0a1a32ed98fb031995151c4c9665592468e2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Reference < ActiveRecord::Base
  belongs_to :person
  belongs_to :job

  has_many :agents_posts_authors, :through => :person

  class << self
    attr_accessor :make_comments
  end

  before_destroy :make_comments

  def make_comments
    if self.class.make_comments
      person.update_attributes :comments => "Reference destroyed"
    end
  end
end

class BadReference < ActiveRecord::Base
  self.table_name = 'references'

  def self.default_scope
    where :favourite => false
  end
end