一键导入
background-jobs
Create and manage Solid Queue background jobs with perform_now vs perform_later patterns
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create and manage Solid Queue background jobs with perform_now vs perform_later patterns
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Perform deep critical analysis of changes with focus on performance vs sustainability trade-offs
Add controllers and routes following project patterns for organizer namespaces, strong params, and Turbo
Build Rails forms with Tailwind CSS, Turbo integration, and strong params validation
Write database migrations for PostgreSQL with PostGIS, UUID primary keys, enums, and counter caches
Create and modify Rails models following project conventions for STI, enums, validations, counter caches, and scopes
Create service objects in app/services/ using module namespaces for encapsulation
基于 SOC 职业分类
| name | background-jobs |
| description | Create and manage Solid Queue background jobs with perform_now vs perform_later patterns |
| license | MIT |
app/jobs/ with module namespacesperform_now (synchronous) and perform_later (async)test/jobs/app/jobs/
application_job.rb
tournaments/
start_swiss_round_job.rb
start_single_elimination_round_job.rb
finish_round_job.rb
finish_tournament_job.rb
create_pods_job.rb
create_single_elimination_pods_job.rb
leagues/
start_play_round_job.rb
start_finals_round_job.rb
finish_league_job.rb
create_pickup_pod_job.rb
events/
geocode_job.rb
submit_result_job.rb
circuits/
update_standings_job.rb
# frozen_string_literal: true
module Namespace
class DescriptionJob < ApplicationJob
discard_on ActiveJob::DeserializationError
def perform(record)
# Job body
end
end
end
perform_now: Synchronous, runs in the same thread, same transaction as caller
Tournaments::StartSwissRoundJob.perform_now(event) in perform_state_based_actionsperform_later: Async, enqueued to Solid Queue, runs after request
Events::GeocodeJob.perform_later(self) in after_save callbackJobs that trigger other jobs:
# In a model or service:
def advance_tournament!
return if last_round?
Tournaments::StartSwissRoundJob.perform_now(event)
end
State changes in models trigger jobs via perform_state_based_actions:
:swiss → StartSwissRoundJob:single_elimination → StartSingleEliminationRoundJob:finished → FinishTournamentJob:play (League) → StartPlayRoundJob:finals (League) → StartFinalsRoundJobclass ApplicationJob < ActiveJob::Base
discard_on ActiveJob::DeserializationError
# retry_on ActiveRecord::Deadlocked — uncomment if needed
end
# test/jobs/namespace/job_name_test.rb
require "test_helper"
class Namespace::JobNameTest < ActiveJob::TestCase
test "job performs expected action" do
record = create :factory_name # if using factory_bot
# or use fixtures
assert_difference "Model.count", 1 do
Namespace::JobName.perform_now(record)
end
end
end
app/jobs/application_job.rb — Base job with discard_onapp/jobs/tournaments/start_swiss_round_job.rb — Minimal job exampleapp/models/swiss_round.rb:33 — Example: perform_now chaining from modelapp/models/event.rb:32 — Example: state-change triggers perform_state_based_actions