From d36b022fae66fc0841335b73b6c7e1a4ecbcaa6e Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Thu, 3 Jan 2019 19:23:37 +0100 Subject: [PATCH] Fix deprecation: returning false in Active Record and Active Model callbacks will not implicitly halt a callback chain --- app/models/list.rb | 2 +- changelogs/unreleased/deprecated-callback-false.yml | 6 ++++++ config/initializers/new_framework_defaults.rb | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/deprecated-callback-false.yml diff --git a/app/models/list.rb b/app/models/list.rb index 029685be927..682af761ba0 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -54,6 +54,6 @@ class List < ActiveRecord::Base private def can_be_destroyed - destroyable? + throw(:abort) unless destroyable? end end diff --git a/changelogs/unreleased/deprecated-callback-false.yml b/changelogs/unreleased/deprecated-callback-false.yml new file mode 100644 index 00000000000..6ba01a75ab9 --- /dev/null +++ b/changelogs/unreleased/deprecated-callback-false.yml @@ -0,0 +1,6 @@ +--- +title: 'Fix deprecation: returning false in Active Record and Active Model callbacks + will not implicitly halt a callback chain' +merge_request: 24134 +author: Jasper Maes +type: other diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index 5adb9f7a4b4..a1e0667bc6f 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -22,6 +22,3 @@ ActiveSupport.to_time_preserves_timezone = false # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = false - -# Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = true