title: Sidekiq Rails 4.2 Use Active Job or Worker? What's the difference
body: <p>This is my first processing jobs asynchronously I am implementing Sidekiq for background processing in my app.  I will use it for reminder emails and in-app notifications.  I am confused as to whether I should use Active Job to create a job that sends an email or a Sidekiq Worker to send an email. They seem to do the same thing and Rails 4.2 Active Job seems very new…is it replacing the need for a Sidekiq Worker?  </p>
  
  <p>Below is the same sending a mailer code using an Active Job job and a Sidekiq Worker.  I am using Whenever gem for scheduling. </p>
  
  <p>my_mailers.rb</p>
  
  <pre><code>class MyMailers &lt; ActionMailer::Base
  
    def some_mailer(r.user_id)
      @user = User.find(r.user_id)
      mailer_name = "ROUNDUP"
      @email = @user.email
      @subject ="subject text"
      mail(to: @email, 
        subject: @subject,  
        template_path: '/notifer_mailers', 
        template_name: 'hourly_roundup.html',
        )
    end
  end
  </code></pre>
  
  <p><strong>Using a Sidekiq "Worker"</strong><br>
  some_worker.rb</p>
  
  <pre><code>class SomeWorker
    include Sidekiq::Worker
  
    def perform()
      @user = User.all
      @reminders = @user.reminders.select(:user_id).uniq.newmade
      @reminders.each do |r|
        MyMailers.some_mailer(r.user_id).deliver_later
      end
    end
  
  end
  </code></pre>
  
  <p><strong>Using an Active Job "Job"</strong><br>
  some_job.rb</p>
  
  <pre><code>class SomeJob &lt; ActiveJob::Base
    queue_as :mailer
  
    def perform()
      @user = User.all
      @reminders = @user.reminders.select(:user_id).uniq.newmade
      @reminders.each do |r|
        MyMailers.some_mailer(r.user_id).deliver_later
      end
    end
  
  end
  </code></pre>
  
  <p><strong>Both Examples in my Whenever scheduler</strong>
  schedule.rb</p>
  
  <pre><code>require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
  set :path, Rails.root
  set :output, Rails.root.join('log', 'cron.log')
  
  #using a worker
  every 1.day, :at =&gt; '4:30 am' do
    runner SomeWorker.perform_async
  end
  
  #using a job
  every 1.day, :at =&gt; '4:30 am' do
    runner SomeJob.perform_async
  end
  </code></pre>