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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:32:46+00:00 2026-06-17T10:32:46+00:00

I have this job on my controller: def action1 #code here order = Order.find(params[:id])

  • 0

I have this job on my controller:

def action1
 #code here
  order = Order.find(params[:id])
  Delayed::Job.enqueue(ExpiredMessage.new(order), 2, 2.days.from_now)
 #code here
end

I have inside myapp/app/jobs a custom job inside a file called expired_message.rb with the next content:

class ExpiredMessage < Struct.new(:order)
 def perform
  #code to run here for example order.save
   order.any_method
 end
end

I want execute the code inside perform method only if order.status == "PA"

How can I run a hook before save the order to check if order.status == "PA" on my custom job?

Otherwise, if the order.status != “PA” I want delete the job before this job is executed.

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-17T10:32:47+00:00Added an answer on June 17, 2026 at 10:32 am

    If you want to check an object’s status from the database – call reload on it. Otherwise, just check it as you would any other object:

    def perform
      order.any_method if order.reload.status == "PA"
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my controller: def show @activity = current_user.activities.find(params[:id]) if
In my Jobs controller I have this statement under the index() function: $this->Job->find('all', array('conditions'
I have a java code that looks like this: //UI thread //Some code Job
I have a method inside my controller that I need execute inside delayed job
I have a job that must execute each monday. This job run in a
I have a table that looks like this: Name Job Year ImpFile ImpDate ------------------------------------------------
I have a job interview tomorrow and I'm trying to answer this question: There
I have a query like this: select empno,name from emp where job = 'CLERK'
I have a webpage that activates a print job on a printer. This works
i have a input like this $desc = &lt;p&gt;\r\n test job description!&lt;/p&gt; i have

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.