简体   繁体   中英

Run a method after 5 minutes of creation of record in model rails

I'm new to rails,

If I send a request to any user and in case if there is not any response from there with in 5 minutes then request send to another user.

How can I do this in rails please suggest me.

You can make use of run_at option provided by delayed job.

class RecordModel < ActiveRecord::Base
   after_create :make_delayed_entry

   def make_delayed_entry
      Delayed::Job.enqueue(SendMailAndWaitJob.new(parameters), 0, 5.minutes.from_now, :queue => "queue_name")
   end
end

SendMailAndWaitJob its the class file(lib file) where you can check request accepted or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM