Skip to content

Commit 35de223

Browse files
committed
Remove superfluous return value from 'before' callbacks
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. Conveniently, all our callbacks return true, so we don't need to do much. See https://guides.rubyonrails.org/v5.2/upgrading_ruby_on_rails.html#halting-callback-chains-via-throw-abort
1 parent d68bf57 commit 35de223

4 files changed

Lines changed: 0 additions & 4 deletions

File tree

app/models/contest.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Contest < ActiveRecord::Base
3636
end
3737

3838
update_contest_scores if finalized_at_was && finalized_at.nil?
39-
true
4039
end
4140

4241
# calculate contest scores again from scratch

app/models/item.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class Item < ActiveRecord::Base
1212

1313
before_create do
1414
self.scan_token = SecureRandom.random_number(100000000)
15-
true
1615
end
1716

1817
def scan_token

app/models/submission.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def user_problem_relation
3333
end
3434
self.evaluation = points.nil? || maximum_points.nil? ? nil : (points / maximum_points).to_f
3535
update_test_messages
36-
true
3736
end
3837

3938
before_create do

app/models/user.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class User < ActiveRecord::Base
1818

1919
before_save do
2020
self.can_change_username = false if username_changed? # can only change username once
21-
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
2221
end
2322

2423
has_many :problems

0 commit comments

Comments
 (0)