title: Ensuring new object has a value greater than all others using Rails and Ruby
body: <p>I am creating an auction house similar to eBay. My question is with my bids resource. It will keep track of all of the bids that are placed. However I MUST ensure that every new bid on an item, is higher than the current bid, otherwise that would defeat the purpose of an auction. </p>
  
  <p>The way I currently want to do this is to create a transaction inside the bids controller, that would check whether or not the amount being bid for an item, is greater than the max of the other bids for the same item. </p>
  
  <pre><code>def create
      bid.transaction 
        @bid = Bid.new(params[:bid])
        @bid.user = current_user
         @bid.item = current_item
         # DO STUFF TO CHECK ITS GREATER THAN MAX OF BIDS FOR CURRENT_ITEM
         # ON ERROR, ROLLBACK TRANSACTION AND THROW ERROR
  
      end
  end
  </code></pre>