askill
vanilla-rails-jobs

vanilla-rails-jobsSafety 95Repository

Use when writing background jobs or async operations - enforces thin job wrappers (3-5 lines) that delegate to models using _later/_now naming pattern

2 stars
1.2k downloads
Updated 2/14/2026

Package Files

Loading files...
SKILL.md

Vanilla Rails Jobs

Jobs are thin wrappers (3-5 lines). ALL business logic lives in models.

The Pattern

# Model concern - WHERE THE LOGIC LIVES
module Card::ClosureNotifications
  extend ActiveSupport::Concern

  included do
    after_update :notify_watchers_later, if: :just_closed?
  end

  def notify_watchers_later
    Card::ClosureNotificationJob.perform_later(self)
  end

  def notify_watchers_now
    watchers.each do |watcher|
      CardMailer.closure_notification(watcher, self).deliver_now
      Notification.create!(user: watcher, card: self, action: 'closed')
    end
  end
end

# Job - ONLY delegates (3 lines)
class Card::ClosureNotificationJob < ApplicationJob
  def perform(card)
    card.notify_watchers_now
  end
end

Flow: Callback → _later → enqueue job → job calls _now → logic executes

Why Thin Jobs

  • Test _now synchronously — no job infrastructure needed
  • Reusable — call _now in console, tests, anywhere
  • Debuggable — stack traces point to model, not job framework

Edge Cases

Multi-model — primary model orchestrates:

class User::DigestJob < ApplicationJob
  def perform(user); user.send_digest_now; end
end

Utility/cleanup — use class methods:

class Session::CleanupJob < ApplicationJob
  def perform; Session.cleanup_expired_now; end
end

Error handling — ActiveJob retries + model errors:

class Card::SyncJob < ApplicationJob
  retry_on ExternalAPI::Error, wait: 5.minutes
  def perform(card); card.sync_to_external_system_now; end
end

Red Flags

Red flagFix
Job > 5 lines (excluding retry_on)Move logic to model
Business logic in jobMove to _now method on model
perform(card_id) then Card.findperform(card) — let ActiveJob serialize
No _later/_now namingAdd suffixes
Missing _now methodAlways create — needed for testing
Job sends emails directlyModel orchestrates, mailer delivers
Job has conditionals/loopsDomain logic goes in model

Quick Check

  • Job is 3-5 lines, calls one model method
  • Receives model instance (not ID)
  • No queries, conditionals, or loops in job
  • Model has _later method (enqueues)
  • Model has _now method (logic)

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

82/100Analyzed 2 weeks ago

A well-structured Rails coding convention skill that enforces thin job wrappers (3-5 lines) with `_later`/`_now` delegation pattern. Provides excellent rationale, multiple edge case examples, a red flags table, and a checklist. Scores high on actionability and clarity; slightly limited reusability due to Rails specificity. Genuine technical reference content, not boilerplate.

95
88
70
80
85

Metadata

Licenseunknown
Version-
Updated2/14/2026
PublisherZempTime

Tags

testing