Delayed Jobs with Heroku

Use Puma

Make sure that you use Puma. To install Puma, add this to your Gemfile:

gem 'puma'

Setup a Profile on your application. Should be located on the same folder as your Gemfile. Add these configs to your Procfile:

web: bundle exec puma -C config/puma.rb
worker: rake jobs:work

Now you can 'bundle install'.

Install Delayed Job

On your Gemfile, add this:

gem 'delayed_job_active_record'

Run bundle install

Then generate delayed jobs migration:

rails g delayed_job:active_record
rake db:migrate

After doing you can now use delayed jobs.

# without delayed_job

# with delayed_job

Sending notifications:

# without delayed_job

# with delayed_job

# with delayed_job running at a specific time
Notifier.delay(run_at: 5.minutes.from_now).signup(@user)

Now you can use Delayed Jobs to any task by adding ‘.delay’ to the method.

Good luck on building your app!