Hello, I’m beginning to test a payment method, here is an abbreviated
form.
How can I rollback and redo the transaction if any of the save calls
fail?
def process_payment! # class Payment
transaction do
success = true
user.blitz_interest = true
user.points += 1
user.blitz_contributes += DIVIDEND
user.credit.pebbles += 1
blitz_fund = BlitzFund.find_or_create_by_dues(DIVIDEND)
blitz_fund.general_pool += DIVIDEND
save
user.save
user.credit.save
blitz_fund.save
end
end