From 0dbc3e4ac159e03e4dcd85c90d3ccd1bb1979134 Mon Sep 17 00:00:00 2001 From: Jonathan Khoo Date: Sun, 6 Jul 2025 00:49:59 +1200 Subject: [PATCH 1/2] Do not halt callback chains when a callback returns false In Rails 5.0, halting a 'before' callback by returning false is deprecated in favour of `throw(:abort)`, and in Rails 5.1 that feature is removed. All our callbacks currently return true, so this shouldn't cause any changes in behaviour. See https://guides.rubyonrails.org/v5.2/upgrading_ruby_on_rails.html#halting-callback-chains-via-throw-abort --- config/initializers/new_framework_defaults.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb index cbf423a8..66bc22ce 100644 --- a/config/initializers/new_framework_defaults.rb +++ b/config/initializers/new_framework_defaults.rb @@ -22,4 +22,4 @@ 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 +ActiveSupport.halt_callback_chains_on_return_false = false From 798324f2933e1a00ec51b7ccf4d0fe1ec3487d64 Mon Sep 17 00:00:00 2001 From: Tom Levy Date: Fri, 4 Jul 2025 00:22:47 +1200 Subject: [PATCH 2/2] Remove superfluous return value from 'before' callbacks These were only necessary to avoid halting callback chains under the previous behaviour. --- app/models/contest.rb | 1 - app/models/item.rb | 1 - app/models/submission.rb | 1 - app/models/user.rb | 1 - 4 files changed, 4 deletions(-) diff --git a/app/models/contest.rb b/app/models/contest.rb index 024ca908..ebe8447e 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -36,7 +36,6 @@ class Contest < ApplicationRecord end update_contest_scores if finalized_at_was && finalized_at.nil? - true end # calculate contest scores again from scratch diff --git a/app/models/item.rb b/app/models/item.rb index dc68a9d5..93594c1e 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -12,7 +12,6 @@ class Item < ApplicationRecord before_create do self.scan_token = SecureRandom.random_number(100000000) - true end def scan_token diff --git a/app/models/submission.rb b/app/models/submission.rb index cb6690ca..1c229178 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -33,7 +33,6 @@ def user_problem_relation end self.evaluation = points.nil? || maximum_points.nil? ? nil : (points / maximum_points).to_f update_test_messages - true end before_create do diff --git a/app/models/user.rb b/app/models/user.rb index 759b8f0c..b6c46b85 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,6 @@ class User < ApplicationRecord before_save do self.can_change_username = false if username_changed? # can only change username once - true # this line should be removed once we upgrade to Rails >= 5.1, see https://guides.rubyonrails.org/5_1_release_notes.html#active-model-removals end has_many :problems