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
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to