mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-23 05:28:53 +00:00
There have been race conditions in other projects using the acts_as_list gem which could be solved by serializing.
14 lines
345 B
Ruby
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
|