title: How can I implement in Rails bid offers that sellers can cancel or accept within 24hrs or transaction is cancelled?
body: <p>I am working on a marketplace in rails that allows buyers to make an offer to the seller as a bid for a listing. The seller can cancel or accept the bid but only has a 24 hr window to do this or the bid expires and the transaction is cancelled. A user can be both a buyer or a seller.</p>
  
  <p>I have an Order model that represents each transaction.</p>
  
  <pre><code>Class Order &lt; ActiveRecord::Base
      belongs_to :seller, class_name: "User"
      belongs_to :buyer, class_name: "User"
      belongs_to :listing
  end
  </code></pre>
  
  <p>On my reservation controller,
      Class OrdersController &lt; Application Controller
          before_action :authenticate_user!</p>
  
  <pre><code>def create 
      @order = Order.new(order_params)
      @seller = @order.listing.user
      @order.buyer_id = current_user.id
      @order.seller_id = @seller.id
      @bidding_fee = @order.bidding_fee
  end
  </code></pre>
  
  <p>I want to differentiate between a buyer cancel and seller cancel because if a seller cancels a bid for a listing  the buyer pays no bidding fee but if the buyer cancels the order he made he is charged a bidding fee. How can the transactions for bids be implemented. The hardest part is figuring out creating a timer in rails that will show the seller how much time is left e.g 4 hrs 12 min before the bid expires and cancelling the bid after 24 hrs if there's no response especially keeping in mind different client side time zones that may be hours apart from the created_at time of the order. I also need to show order status as pending, canceled or accepted which rules out boolean functionality because that creates three possible statuses. Any kind of help in any of these problems would be greatly appreciated. </p>