So I am following http://dry-rb.org/gems/dry-transaction/around-steps/ and i have decided to try out transactions in my app
my transaction looks something like this
class MyTransaction
include Dry::Transaction(container: MyContainer)
around :transaction, wtih: 'transaction'
step :create_one
step :create_two
end
and my around transaction looks like this from my container
register('transaction') do |input, &block|
result = nil
begin
ActiveRecord::Base.transaction do
binding.pry
result = block.call(Success.new(input))
binding.pry
raise ActiveRecord::Rollback if result.failure?
result
end
rescue ActiveRecord::Rollback
# the code never reached here...
result
end
end
it works fine when there are no failures, but when a failure occurs… I get this error Dry::Transaction::InvalidResultError (step +transaction+ must return a Result object)
from the around transaction… i tried debugging to see what seems to be the cause but control doesn’t seem to enter the rescue block
did i do something wrong with my around step?