aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/comment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/models/comment.rb')
-rw-r--r--activerecord/test/models/comment.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb
index 6a9dfacf56..ea261ac9ec 100644
--- a/activerecord/test/models/comment.rb
+++ b/activerecord/test/models/comment.rb
@@ -26,6 +26,10 @@ class Comment < ActiveRecord::Base
all
end
scope :all_as_scope, -> { all }
+
+ def to_s
+ body
+ end
end
class SpecialComment < Comment
@@ -37,3 +41,11 @@ end
class VerySpecialComment < Comment
scope :special_parent, -> (special_rating) { where parent_id: special_rating.special_comment.id }
end
+
+class CommentThatAutomaticallyAltersPostBody < Comment
+ belongs_to :post, class_name: "PostThatLoadsCommentsInAnAfterSaveHook", foreign_key: :post_id
+
+ after_save do |comment|
+ comment.post.update_attributes(body: "Automatically altered")
+ end
+end