Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:41:29+00:00 2026-05-22T21:41:29+00:00

My app has deals where orders are made once a minimum order amount is

  • 0

My app has deals where orders are made once a minimum order amount is met. Currently I have setup orders that that orders are placed right after the order is submitted which is all working.

Now I need to change the process so that orders are processed once the minimum order number for the deal is met.

Should I use delayed_job for this or maybe a cron process?

Here is the process I was thinking of following.

Delaying Orders Until Orders minimum is met

  1. Find deals that are still active
  2. Then find deals where minimum number of orders are met
  3. For each deals orders, loop through and process capture on each order.
  4. Send confirmation of orders.

My order model purchase method

def purchase
    response = OrderTransaction.gateway.purchase(order_amount, credit_card, options)
    transactions.create!(:action => "purchase", :amount => order_amount, :response => response)
    response.success?
end

My create method in my orders controller.

def create
    @member  = current_member
    @order_deal = Deal.find(params[:deal_id])
    @order = @order_deal.orders.build(params[:order])
    @order.member_id = current_member.id
    @order.ip_address = request.remote_ip
    @deal = @order_deal
    if @order.save
      if @order.purchase
        MessageMailer.order_receipt(@order, @member).deliver
        render :action => "success"
        flash[:notice] = "Successfully created order."
      else 
        render :action => "new"
      end
    else
      render :action  => 'new'
    end
 end

I’m running this application on Heroku. Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:41:30+00:00Added an answer on May 22, 2026 at 9:41 pm

    If I understand correctly basically a bunch of people have to place an order before anyone gets the deal, like groupon. If so, a simpler way might be simply to check if the minimum number of orders have been placed every time a new order is placed. So say the minimum is two orders, you place the first and your order is logged to the db but not processed, then I place my order. When my order is placed your application it triggers a condition, probably in the model layer via before_save, and then the app pulls all of the orders for the deal and processes them. This implementation is nice because you don’t have to constantly be checking with a secondary process (delayed job) to see if the minimum has been met. Delayed Job might be helpful for processing all of the orders once the threshold is met.

    Here is some sample code for a model (you could also do it in the controller in theory)

    before_save :check_if_minimum_has_been_met
    
    def check_if_minimum_has_been_met
    
      if deal.minimum_orders < deal.orders + 1 #to count the current order
        #execute the delayed job/order processing
      else
        #do nothing....
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iPad app that submits orders to an ASP.NET MVC web site
Suppose I have a Rails app that deals with Posts and Comments . A
I'm writing an app that deals with Albums of pictures. I have the following
I have a Winform app that has a backgroundWorker thread and does all operations
I'm writing my first PHP app that has to directly deal with dates, and
My app has some table cells that vary in height. The cells can also
We have a C# client app that communicates to our C# backend service via
Im developing an iPhone app that has an groupchat. Im using the XMPP framework.
I have an app which has a UINavigationController, which has a couple of UIViewControllers.
I'm writing an app that has a wizard type input section. Think MS Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.