nitzan
nitzan

Reputation: 329

Performing a transaction with Rails ar-octopus gem

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.

Upvotes: 3

Views: 624

Answers (1)

Haim Hamou
Haim Hamou

Reputation: 121

Instead of passing &block you can do the following :

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

Upvotes: 4

Related Questions