Files
openfoodnetwork/lib/open_food_network/locking.rb
Maikel Linke c01d45e3af Serialize move_up and move_down methods of groups
There have been race conditions in other projects using the acts_as_list
gem which could be solved by serializing.
2015-02-19 16:51:58 +11:00

14 lines
345 B
Ruby

module OpenFoodNetwork::Locking
# http://rhnh.net/2010/06/30/acts-as-list-will-break-in-production
def with_isolation_level_serializable
self.transaction do
self.connection.execute("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE")
yield
end
end
end
class ActiveRecord::Base
extend OpenFoodNetwork::Locking
end