title: How to perform Asynchrnous task in rails using delayed_jobs?
body: <p>Task: 
  Delete an item in <code>Async</code> manner [HomeWork]</p>
  
  <p>I have already configured <code>Active jobs</code> with <code>delayed_jobs</code> in my rails application but I am still confused about performing <code>Async</code> task in rails project. </p>
  
  <p>Let's take an example:
  I have some item to delete from the database but I want to do it in <code>Async</code> manner. I also read about <code>perform_later</code> or <code>perform_now</code> method in <code>delayed_job</code> blogs. Here is my code which is working fine:</p>
  
  <h1>Controller class</h1>
  
  <pre><code> def destroy
     PostJob.perform_now(params[:id])
     respond_to do |format|
      format.xml  { head :ok }
      format.js { render 'posts.js.erb' }
    end
   end
  </code></pre>
  
  <h1>Job class</h1>
  
  <pre><code>class PostJob &lt; ActiveJob::Base
   queue_as :default
  
   def perform(id)
    @post = Post.find(id)
    @post.destroy
   end
  end
  </code></pre>
  
  <p>According to <a href="https://github.com/collectiveidea/delayed_job#queuing-jobs" rel="nofollow">official doc</a> of delayed_jobs I can add <code>handle_asynchronously</code> in the end of method to run in <code>async</code> manner. How can I implement in this case?</p>
  
  <h1>My Question:</h1>
  
  <ol>
  <li>When I am looking at <code>destroy</code> method it is not deleting the element in <code>Async</code> way. However every steps written in <code>destroy</code> method is in <code>Synchronous</code>. Am I wrong?</li>
  <li>If it's not then How can I implement <code>destroy</code> method to delete <code>post</code> in async manner?</li>
  <li>Backgrounding task and cron job are same thing?</li>
  </ol>
  
  <h1>Edit -1</h1>
  
  <p>After giving suggestion by A Fader Darkly, I changed <code>perform_now</code> to <code>perform_later</code> which is working perfectly for <code>Async</code> process but it is not deleting the entry from table (code is fine because it works when i user <code>perform_now</code>). </p>
  
  <p>Also when I am running job manually by following command, Everything works fine:</p>
  
  <pre><code>rake jobs:work
  </code></pre>
  
  <p>Is there any way to execute <code>delay_job</code> task as soon as the <code>queue</code> get some new data? </p>