I'm building an auction-like system in Rails 3 (using PostgreSQL as the database).
Imagine you have a Product. A product has many Bids.
I'm worried with what happens when 2 different users click "Bid" at the same time (providing I have at least 2 application servers, and they hit the servers at the same time). I have two possible acceptable behaviors for this:
- one of them "wins", and the other receives an error message
- one of them "wins", and the other bid is created next (each bid adds 0.01€ to the price). So all the concurrent bids are repeated until created
So my question is: how to handle this problem on Rails 3? I think using regular transactions isn't enough, or is it?