rails-background-jobs
Installation
SKILL.md
Rails Background Job Conventions
A job's body is a thin adapter: fetch records by ID, delegate to a service, done. No business logic lives in the job class itself.
Jobs Delegate to Services
# Wrong — business logic inline in the job
class SendWeeklyDigestJob < ApplicationJob
def perform(user_id)
user = User.find(user_id)
return if user.unsubscribed?
posts = Post.published.where("created_at > ?", 1.week.ago)
DigestMailer.weekly(user, posts).deliver_now
end
end