Skip to content
Permalink
Browse files

Fix race condition when updating competition tabs order.

  • Loading branch information...
jonatanklosko committed Aug 2, 2019
1 parent e5a9bcb commit b6aaffab6381acc863913fb323259f96b62f640a
Showing with 5 additions and 3 deletions.
  1. +5 −3 WcaOnRails/app/models/competition_tab.rb
@@ -39,9 +39,11 @@ def reorder(direction)
other_display_order = display_order + (direction.to_s == "up" ? -1 : 1)
other_tab = competition.tabs.find_by(display_order: other_display_order)
if other_tab
update_column :display_order, nil
other_tab.update_column :display_order, current_display_order
update_column :display_order, other_display_order
ActiveRecord::Base.transaction do
update_column :display_order, nil
other_tab.update_column :display_order, current_display_order
update_column :display_order, other_display_order
end
end
end
end

0 comments on commit b6aaffa

Please sign in to comment.
You can’t perform that action at this time.