diff options
author | Agis- <corestudiosinc@gmail.com> | 2014-10-13 17:50:32 +0300 |
---|---|---|
committer | Agis- <corestudiosinc@gmail.com> | 2014-10-13 17:50:32 +0300 |
commit | 719d52db42a0eeebf0f1fa2f8ac3173544dd521e (patch) | |
tree | 63b18091ff85b230f4708f0ebfad5b6e6f362562 /activerecord/test/models | |
parent | 51278579477eb7ee20fe2aba53b4b13203791b22 (diff) | |
download | rails-719d52db42a0eeebf0f1fa2f8ac3173544dd521e.tar.gz rails-719d52db42a0eeebf0f1fa2f8ac3173544dd521e.tar.bz2 rails-719d52db42a0eeebf0f1fa2f8ac3173544dd521e.zip |
Autosave callbacks shouldn't be `after_save`
068f092ced8483e557725542dd919ab7c516e567 registered autosave callbacks
as `after_save` callbacks. This caused the regression described in #17209.
Autosave callbacks should be registered as `after_update` and
`after_create` callbacks, just like before.
This is a partial revert of 068f092ced8483e557725542dd919ab7c516e567.
Fixes #17209.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/post.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 256b720c9a..67027cbc22 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -219,6 +219,15 @@ class PostThatLoadsCommentsInAnAfterSaveHook < ActiveRecord::Base end end +class PostWithAfterCreateCallback < ActiveRecord::Base + self.table_name = 'posts' + has_many :comments, foreign_key: :post_id + + after_create do |post| + update_attribute(:author_id, comments.first.id) + end +end + class PostWithCommentWithDefaultScopeReferencesAssociation < ActiveRecord::Base self.table_name = 'posts' has_many :comment_with_default_scope_references_associations, foreign_key: :post_id |