3

I couldn't find in ar-octopus (https://github.com/tchandy/octopus) documentation, how can i perform a transaction.

When performing :

ActiveRecord::Base.connection.transaction do
     Octopus.using(:shard, &block)
end

the code in the block isn't running in a transaction.

Please advise.

nitzan
  • 319
  • 1
  • 14

1 Answers1

4

Instead of passing &block you can do the following :

Octopus.using(:shard) do
    ActiveRecord::Base.connection.transaction do
        block.call   
    end    
end
Haim Hamou
  • 121
  • 4
  • This appears to just work now with the latest Octopus. Is anyone still needing to explicitly wrap transactions with a `using` block? – Shyam Habarakada Mar 07 '18 at 15:18