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 8646327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:46:44+00:00 2026-06-12T12:46:44+00:00

I have a method inside my controller that I need execute inside delayed job

  • 0

I have a method inside my controller that I need execute inside delayed job method:

This is my order controller action:

class OrdersController < ApplicationController

 def create
  #code here
  order = Order.first
  Order.delay(queue: "order", priority: 1, run_at: 2.minutes.from_now).expire_order(order)
 end

 def template_expired_order(order)
  #code here
 end

end

This is my order model:

class Order
  include Mongoid::Document
  include Mongoid::Timestamps::Created
  .
  .
  .
  #delayed jobs method
  def self.expire_order(order)
   #code here
  end
end

I want execute the controller method template_expired_order(order) when self.expire_order(order) method is executed or triggered or fired up.

How can I do it?

Thank you very much!

  • 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-06-12T12:46:45+00:00Added an answer on June 12, 2026 at 12:46 pm

    You should not put model-related code in the controller, especially if you want to run it in a background job. It’s not clear what template_expired_order does, but I would recommend putting it in the Order model and calling it directly on the order that gets pass into expired_order.

    class Order
      def expire_order(order)
        order.template_expired_order
      end
    
      def template_expired_order
        # code
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few methods inside my view controller that load up for future
I have a variable @products = Product.all defined inside new method in a controller.
Setup: I have a COM DLL that calls a method inside a managed C#
Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I
Hi I have this simple method which gets triggered when i click inside a
Hallo, I have following jquery code for calling ASP.NET MVC controller method that is
I need a method of inserting javascript which is controller/action specific into a layout.
can i call helper functions inside controller classes? let's say i have this controller
I have this non standard situation where i need to update object inside readOnly
Short: Is there a way to have a route-definition that will pass the CONTROLLER/ACTION

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.