You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
beginrequire'bundler/inline'rescueLoadError=>e
$stderr.puts'Bundler version 1.10 or later is required. Please update your Bundler'raiseeendgemfile(true)dosource'https://rubygems.org'gem'activerecord',"6.0.3"gem'sqlite3'endrequire'active_record'require'minitest/autorun'require'logger'Minitest::Test=MiniTest::Unit::TestCaseunlessdefined?(Minitest::Test)ActiveRecord::Base.establish_connection(adapter: "sqlite3",database: ":memory:")ActiveRecord::Base.logger=Logger.new(STDOUT)ActiveRecord::Schema.definedocreate_table:post_items,force: truedo |t|
t.string:titleendendclassPostItem < ActiveRecord::Baseafter_commit:my_callback,on: :updateprivatedefmy_callbackputs"#{id}: previous_changes = #{previous_changes.inspect}"endendclassBugTest < Minitest::Testdeftest_stuffPostItem.create!PostItem.create!PostItem.transactiondoPostItem.first.update!(title: "first post title update 1")PostItem.first.update!(title: "first post title update 2")PostItem.last.update!(title: "last post title update 1")PostItem.last.update!(title: "last post title update 2")endendend
Expected behavior
Output:
1: previous_changes = {"title"=>[nil, "first post title update 2"]}
2: previous_changes = {"title"=>[nil, "last post title update 2"]}
Actual behavior
Output:
1: previous_changes = {"title"=>[nil, "first post title update 1"]}
2: previous_changes = {"title"=>[nil, "last post title update 1"]}
System configuration
Rails version: 6.0.3 Ruby version: 2.7.1
Full logs
D, [2020-08-02T18:00:29.208603 #5622] DEBUG -- : (0.1ms) begin transaction
D, [2020-08-02T18:00:29.208798 #5622] DEBUG -- : PostItem Create (0.1ms) INSERT INTO "post_items" DEFAULT VALUES
D, [2020-08-02T18:00:29.209030 #5622] DEBUG -- : (0.0ms) commit transaction
D, [2020-08-02T18:00:29.209380 #5622] DEBUG -- : (0.0ms) begin transaction
D, [2020-08-02T18:00:29.209490 #5622] DEBUG -- : PostItem Create (0.1ms) INSERT INTO "post_items" DEFAULT VALUES
D, [2020-08-02T18:00:29.209598 #5622] DEBUG -- : (0.0ms) commit transaction
D, [2020-08-02T18:00:29.210048 #5622] DEBUG -- : (0.0ms) begin transaction
D, [2020-08-02T18:00:29.210218 #5622] DEBUG -- : PostItem Load (0.1ms) SELECT "post_items".* FROM "post_items" ORDER BY "post_items"."id" ASC LIMIT ? [["LIMIT", 1]]
D, [2020-08-02T18:00:29.210661 #5622] DEBUG -- : PostItem Update (0.0ms) UPDATE "post_items" SET "title" = ? WHERE "post_items"."id" = ? [["title", "first post title update 1"], ["id", 1]]
D, [2020-08-02T18:00:29.210884 #5622] DEBUG -- : PostItem Load (0.0ms) SELECT "post_items".* FROM "post_items" ORDER BY "post_items"."id" ASC LIMIT ? [["LIMIT", 1]]
D, [2020-08-02T18:00:29.211132 #5622] DEBUG -- : PostItem Update (0.0ms) UPDATE "post_items" SET "title" = ? WHERE "post_items"."id" = ? [["title", "first post title update 2"], ["id", 1]]
D, [2020-08-02T18:00:29.211340 #5622] DEBUG -- : PostItem Load (0.0ms) SELECT "post_items".* FROM "post_items" ORDER BY "post_items"."id" DESC LIMIT ? [["LIMIT", 1]]
D, [2020-08-02T18:00:29.211581 #5622] DEBUG -- : PostItem Update (0.0ms) UPDATE "post_items" SET "title" = ? WHERE "post_items"."id" = ? [["title", "last post title update 1"], ["id", 2]]
D, [2020-08-02T18:00:29.211746 #5622] DEBUG -- : PostItem Load (0.0ms) SELECT "post_items".* FROM "post_items" ORDER BY "post_items"."id" DESC LIMIT ? [["LIMIT", 1]]
D, [2020-08-02T18:00:29.211973 #5622] DEBUG -- : PostItem Update (0.0ms) UPDATE "post_items" SET "title" = ? WHERE "post_items"."id" = ? [["title", "last post title update 2"], ["id", 2]]
D, [2020-08-02T18:00:29.212094 #5622] DEBUG -- : (0.0ms) commit transaction
1: previous_changes = {"title"=>[nil, "first post title update 1"]}
2: previous_changes = {"title"=>[nil, "last post title update 1"]}
The text was updated successfully, but these errors were encountered:
chrismaximin
changed the title
after_commit(on: :update_ is only triggered with the changes of the first changes to the record
after_commit(on: :update) is only triggered with the changes of the first changes to the record
Aug 2, 2020
chrismaximin
changed the title
after_commit(on: :update) is only triggered with the changes of the first changes to the record
after_commit(on: :update) is only triggered with the changes of the first update to the record
Aug 2, 2020
Steps to reproduce
Expected behavior
Output:
Actual behavior
Output:
System configuration
Rails version: 6.0.3
Ruby version: 2.7.1
Full logs
The text was updated successfully, but these errors were encountered: