aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/parrot.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/models/parrot.rb')
-rw-r--r--activerecord/test/models/parrot.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/activerecord/test/models/parrot.rb b/activerecord/test/models/parrot.rb
index ddc9dcaf29..1e5f9285a8 100644
--- a/activerecord/test/models/parrot.rb
+++ b/activerecord/test/models/parrot.rb
@@ -3,21 +3,26 @@ class Parrot < ActiveRecord::Base
has_and_belongs_to_many :pirates
has_and_belongs_to_many :treasures
- has_many :loots, :as => :looter
+ has_many :loots, as: :looter
alias_attribute :title, :name
validates_presence_of :name
attr_accessor :cancel_save_from_callback
- before_save :cancel_save_callback_method, :if => :cancel_save_from_callback
+ before_save :cancel_save_callback_method, if: :cancel_save_from_callback
def cancel_save_callback_method
throw(:abort)
end
+
+ before_update :increment_updated_count
+ def increment_updated_count
+ self.updated_count += 1
+ end
end
class LiveParrot < Parrot
end
class DeadParrot < Parrot
- belongs_to :killer, :class_name => 'Pirate', foreign_key: :killer_id
+ belongs_to :killer, class_name: "Pirate", foreign_key: :killer_id
end