aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/contract.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/models/contract.rb')
-rw-r--r--activerecord/test/models/contract.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/models/contract.rb b/activerecord/test/models/contract.rb
new file mode 100644
index 0000000000..f273badd85
--- /dev/null
+++ b/activerecord/test/models/contract.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class Contract < ActiveRecord::Base
+ belongs_to :company
+ belongs_to :developer, primary_key: :id
+ belongs_to :firm, foreign_key: "company_id"
+
+ before_save :hi
+ after_save :bye
+
+ attr_accessor :hi_count, :bye_count
+
+ def hi
+ @hi_count ||= 0
+ @hi_count += 1
+ end
+
+ def bye
+ @bye_count ||= 0
+ @bye_count += 1
+ end
+end