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
When a record is created then destroyed, after_commit on create callbacks are called.
Steps to reproduce
Run the following ruby script:
require'bundler/inline'gemfile(true)dosource'https://rubygems.org'git_source(:github){ |repo| "https://github.com/#{repo}.git"}# Activate the gem you are reporting the issue against.gem'activerecord','6.0.0'# gem 'activerecord', '5.2.6' # this version worksgem'paranoia'gem'sqlite3'gem'byebug'endrequire'active_record'require'minitest/autorun'require'paranoia'ActiveRecord::Base.establish_connection(adapter: 'sqlite3',database: ':memory:')ActiveRecord::Schema.definedocreate_table:users,force: truedo |t|
t.integer:value,default: 0t.datetime:created_att.datetime:updated_att.datetime:deleted_atendendclassUser < ActiveRecord::Baseacts_as_paranoidafter_commit->{self.value += 1},on: :createendclassBugTest < Minitest::Testdeftest_freshly_loaded_modeluser=User.create!user.destroy# This should fail but it succeedsassertuser.value == 2endend
Note that if you called transaction_include_any_action?([:create]) inside the callback function it will return true which is wrong since the action is destroy not create.
The text was updated successfully, but these errors were encountered:
When a record is created then destroyed, after_commit on create callbacks are called.
Steps to reproduce
Run the following ruby script:
Note that if you called
transaction_include_any_action?([:create])
inside the callback function it will return true which is wrong since the action is destroy not create.The text was updated successfully, but these errors were encountered: