How a Temporal Ruby SDK with Rails integration fits your application
The Temporal Ruby SDK with Rails integration lets a Rails team move long-running or retry-heavy background work onto durable workflows without rewriting the application around a new framework. Rails code stays in charge of the request, the models and the user-facing logic, and it hands work to Temporal by starting a workflow through a Temporal client. The workflow and activity code then runs in separate Ruby worker processes that poll a task queue, so the work survives process restarts, deploys and transient failures of the services it calls. Confirm the supported Ruby SDK version and the exact Rails integration setup against the current Ruby SDK documentation before you design around them, because those details change between releases and should not be assumed from this overview.
Treat the split between the Rails web process and the Ruby workers as the first architectural decision. The client side needs connection settings for the Temporal service, a namespace and credentials, while the worker side needs its own deployment, scaling and shutdown behavior. Temporal server is licensed under the MIT license, and you can run it yourself or use Temporal Cloud, which Temporal Technologies sells as a managed service. Your choice between the two changes who operates the persistence, the frontend and the upgrades, so settle it before you decide where workers run next to Rails. Identify which existing Sidekiq or Active Job jobs are candidates, and which ones depend on side effects that must be wrapped as activities so retries stay safe.
Plan for the points where a Rails team usually trips. Workflow code must be deterministic, so anything that reads the clock, random values or external state belongs in activities, and your team should review that boundary before the first deploy. Keep Rails-only objects such as ActiveRecord connections out of workflow code, and confirm how the integration loads Rails into worker processes so database pools are sized for both web and worker traffic. Ask your team to verify these behaviors in a staging environment with the SDK version you intend to run, and record the results as the baseline for later changes.
What a Rails team needs before the first worker runs
A Rails team can move background jobs onto Temporal only after six things are in place: a supported server line, a persistence store, a compatible Ruby and Rails pair, reachable network paths, certificates where mTLS applies, and a namespace per environment. Each item is a decision with a failure mode, so confirm them together before any worker is written.
Supported Temporal Server line
Pick a server line that Temporal currently supports and start on the latest patch of that minor version. Temporal Server v1.32.1 was published on October 8, 2026, and patch releases v1.31.4 and v1.30.8 followed on October 12, 2026 for earlier lines. Confirm with the SDK documentation that the Ruby SDK works against the server version you choose, and record that pairing in your environment inventory.
Temporal releasesPersistence store from the supported list
Temporal stores workflow state in a persistence database that must come from its tested list. The documented options are Cassandra, PostgreSQL and MySQL, with SQLite reserved for development and testing only. Choose the store your platform team can back up, restore and upgrade, and confirm the exact version range in the persistence documentation before provisioning.
- Tested PostgreSQL range
- PostgreSQL 13 to 16
Ruby and Rails versions
Confirm the Ruby and Rails versions your chosen Temporal Ruby SDK supports from its own documentation, not from memory or from a blog post. Rails applications often run older Ruby patch levels than the SDK requires, so check the application's current runtime against that list. A mismatch here usually shows up as a failed bundle install or a worker that cannot load, which is cheaper to find before the first worker is built.
Network paths to the frontend
Rails web processes that start workflows and the worker processes that execute them both need a route to the Temporal frontend. Temporal documents that its services should run on hosts not reachable from the public internet, so restrict the path to trusted internal networks. Map each source (web pods, job runners, worker hosts) to the frontend address and confirm that firewall and security group rules allow it in every environment.
TLS certificates for mTLS
If the cluster enforces mutual TLS, each Rails and worker client needs a client certificate that the frontend trusts, plus the matching CA chain. Self-hosted Temporal has separate mTLS settings for internode and frontend traffic, so confirm which path your certificates cover. Plan issuance, rotation and renewal alerts before go-live, because an expired client certificate stops workers without a clear error in the Rails logs.
Security docsA namespace per environment
Create a separate Temporal namespace for each environment, such as development, staging and production, so that workflow histories, task queues and access rules do not mix. Ask the platform team who creates namespaces, how retention is set for each one, and how Rails configuration selects the right namespace at deploy time. Without this, a staging worker can pick up production tasks on a shared queue name.
How Rails, the Temporal frontend and Ruby workers connect
The diagram starts in the Rails web process or a job enqueuer, which uses a Temporal client to start a workflow on the Temporal frontend. The frontend records workflow history in the persistence database, and separate Ruby worker processes poll a task queue to run workflow and activity code. Activities call the application database and external APIs, so those calls sit outside the Temporal services. The dashed trust boundary marks the self-hosted services and internal network, and the Temporal Cloud path shows the managed alternative as a second frontend. Check which network paths the workers need and where each activity's credentials come from.
Rails starts workflows on the Temporal frontend, and Ruby workers execute them.
Configuring the Ruby SDK and Rails integration in order
This sequence takes a Rails team from an unconfigured project to a worker that runs a workflow end to end, with a check at each step so problems surface before application code depends on them. It produces a pinned SDK, environment-specific connection settings, a working namespace and task queue, and a verified first execution visible in the Web UI.
Confirm and pin the Ruby SDK version
Before adding the gem, check the Ruby SDK version and the Rails integration guidance in the Temporal documentation, then confirm which Temporal Server version your environment runs against. Add the gem to the Gemfile with an exact version constraint, run bundle install, and commit the Gemfile.lock. Done means bundle exec can load the Temporal client library in a rails runner session without errors and the pinned version appears in the lock file. Confirm the server and SDK pairing with your Temporal contact or the release notes, since the server upgrade rules differ from SDK rules.
Configure client connection settings per environment
Define the target address, namespace, and TLS settings for each environment (development, staging, production) through environment variables or Rails credentials, not hard-coded values. Development usually points at a local server, while production may use mTLS certificates or a Temporal Cloud endpoint, so ask your platform team which certificate authority and key paths apply. Done means a rails runner script can open a client connection to each environment's target and receive a successful response from the service without authentication errors.
Create the namespace and task queue
Create a dedicated namespace for the application so its workflows, retention settings, and access rules stay separate from other teams. Then name a task queue for this application's workers, using a name that reflects the service and environment. Confirm the namespace is registered on the server and that the retention period is set by your team rather than left at a default you have not reviewed. Done means the namespace appears in the Web UI or in the server's namespace listing, and the task queue name is recorded in the application's configuration.
Define one workflow and one activity
Write a small workflow that calls one activity, and keep all database and Rails model access inside the activity, not inside the workflow method. Workflow code must be deterministic, so reading an ActiveRecord model, the current time, or random values there can break replay after a deploy. Pass identifiers into the workflow and let the activity load records. Done means both classes load in a Rails console, the workflow registers with the worker's task queue, and a code review confirms no model calls or non-deterministic calls appear in the workflow body.
Start the worker as a separate process
Run the worker from its own entry point, such as a rake task or a small script under bin/, as a process separate from the Rails web server. This lets you scale, restart, and deploy workers without touching web traffic. Ensure the worker uses the same task queue name and namespace as the client settings. Done means the Web UI shows the worker polling the task queue, and the worker logs show it connected without errors. Repeat the check in each environment before going further.
Start a workflow from Rails
Call the workflow from a controller action or a Rails console, passing the identifiers it needs and a workflow ID that your application can later look up. Use a deterministic ID scheme, such as a business key, so duplicate requests can be detected. Keep the start call short and handle connection errors explicitly, since the web request should not wait on workflow completion. Done means the call returns a workflow handle with the expected ID, and the execution appears in the Web UI as running or completed.
Run an end-to-end check and review history
Trigger the workflow from the Rails entry point you plan to use in production, then open the execution in the Web UI and inspect its event history. You should see the workflow started, the activity scheduled, started, and completed, and the workflow reaching the completed status. Test a failure path too by making the activity raise an error in a non-production environment and confirming the retry events appear. Done means one successful run and one observed failure are both recorded in history, and the team has signed off on the configuration for the next stage.
Deciding whether workers run inside Rails or beside it
The first decision is whether Temporal workers share a process with the Rails web application or run as their own processes or containers. Running workers in the Rails process couples two workloads that scale and fail differently. A deploy of the web tier also redeploys the workers, so a change to activity code forces a web restart, and a long-running activity competes with request threads for memory and CPU. Separate processes let you size worker capacity to the task queue backlog rather than to request traffic, and let you roll the worker tier on its own schedule. Confirm with the Ruby SDK documentation whether it supports in-process workers and what process model it recommends for production before you commit to either layout, because that recommendation should decide the default.
Shutdown behavior is where the two layouts differ most in practice. A Rails deploy usually sends a termination signal and gives the process a grace period to finish in-flight requests. Workers hold activity tasks that may run for minutes or hours, so you need to confirm how the SDK drains or cancels running activities on shutdown, how long it waits, and whether a rolling deploy can cut off work that is not idempotent. Separate worker processes make it easier to set a grace period that matches your longest activity and to stop pulling new tasks before the old process exits. Test this with a deploy during a busy queue, not only with an idle one.
Whichever layout you choose, keep Rails request code out of workflow code. Workflows must be deterministic and replayable, so they cannot call ActiveRecord, read Rails.cache, use Time.now or depend on request-scoped objects such as current_user or Current attributes. Put database and HTTP calls in activities, and pass identifiers and plain data into workflow inputs. Use the same discipline in both layouts, because a worker that loads the full Rails stack will tempt engineers to reach for request helpers inside workflows. A code review check that flags Rails constants inside workflow classes is a cheap control to add early.
Moving background jobs onto Temporal by job type
Short jobs that finish in one attempt and can safely run twice are the lowest-risk candidates. For these, the main change is often the enqueue call: the job is started as a Temporal workflow instead of being pushed onto Sidekiq or Active Job, and the existing method body usually becomes a single activity. Keep the workflow thin, since it exists mainly to give you retries, visibility and a durable record. Many teams can leave these jobs on the existing queue for a time while the Temporal path is proven elsewhere.
- Code shape: the Rails caller starts a workflow with a typed input rather than passing a serialized Ruby object, so pass IDs and small values only.
- Activity boundary: the job body that performs the database write or HTTP call becomes the activity, with its retry policy set on the activity options.
- Idempotency: make the write keyed by a business ID or idempotency key so a retry after a timeout does not create a duplicate record or charge.
- Test before cutover: run the old and new paths against the same inputs in staging and compare side effects, including what happens when the activity times out and retries.
- Parallel run: send a small share of traffic or a copy of the job to the Temporal path and compare outcomes before switching the caller.
Confirm in the Ruby SDK documentation which retry and timeout options apply to activities and how the Rails integration starts workflows from application code.
Jobs that call several services in sequence, where a failure in step three should not repeat steps one and two, are where Temporal replaces hand-built state machines. A workflow records each completed activity in its history, so a retry resumes from the failed step. The cost is discipline: all workflow code must be deterministic, and anything that touches the outside world must sit in an activity. Plan compensation for steps that cannot be undone, such as a refund after a payment capture.
- Code shape: split the existing job into named steps, each becoming an activity, and keep the sequencing and branching in the workflow method.
- Retry policy: set retry behavior per activity according to whether the downstream call is safe to repeat, and mark errors that should never be retried as non-retryable.
- Idempotency: every activity needs a stable key derived from the workflow ID so that a step that succeeded before a crash is not executed twice.
- State and payloads: keep workflow state small, store large records in your database, and pass references between steps.
- Test before cutover: exercise failure at each step in a test environment, confirm compensation runs, and replay recorded histories against the new workflow code before every deployment.
Confirm the Ruby SDK's support for non-retryable error types and any compensation helpers before you design the saga.
Some jobs wait for an approval, a file from a partner, or a webhook that may arrive days later. Holding a Rails worker thread for that wait is fragile. In Temporal, the workflow can wait durably, and an external event moves it forward. The design question is how the outside event reaches the workflow: through a signal sent from a Rails controller or webhook handler, or through a polling activity that checks the external system. Each option has different failure modes, so decide it per job.
- Code shape: the workflow blocks on a condition or a named signal, with a timeout that defines what happens if no answer arrives.
- Activity boundary: the call that notifies a person or submits a request to a partner is an activity, and the wait itself is never placed inside one.
- Idempotency: signal handlers must tolerate duplicates, and the workflow ID should map to the business object so the right instance receives the event.
- Operational state: decide who can inspect, cancel or continue a waiting workflow, and how that appears in your support tooling.
- Test before cutover: test the timeout path, the late-arrival path and the duplicate-signal path, not only the happy path.
Confirm in the Ruby SDK documentation the exact signal, query and timer APIs and their current maturity before you commit a design to them.
Cron-style jobs are tempting to move first because they look simple, but scheduling behavior is where teams most often get surprised. Decide whether the schedule lives in Temporal's scheduling feature or stays in your existing scheduler, and do not run both during the parallel period, because duplicate runs can double-send emails or double-post ledger entries. Overlap, catch-up after downtime and pause behavior should be chosen deliberately rather than left at defaults.
- Code shape: the recurring work becomes a workflow started by a schedule, with the schedule definition kept in version control.
- Overlap policy: choose whether a run skips, buffers or cancels when the previous run is still active, and write that choice down.
- Catch-up behavior: decide what happens to missed runs after a worker or cluster outage, since a backlog can be harmful for some jobs.
- Idempotency: each run should be keyed by its scheduled time so a rerun for the same window does not repeat the side effect.
- Test before cutover: verify the schedule fires at the expected times in staging, pause and resume it, and confirm that the old scheduler is disabled before the new schedule is enabled.
Confirm in the Ruby SDK documentation which schedule options are available and how they are managed from Rails code.
How Rails objects, job arguments and identities map to workflow inputs
This table maps common Rails concepts to their Temporal equivalents and gives the rule that governs each one. Read it before writing the first workflow signature, because most Rails-to-Temporal bugs start with passing a whole model or reading the clock inside workflow code. Confirm serialization and context propagation details in the Ruby SDK documentation before relying on any of these rules.
| Rails concept | Temporal equivalent | Rule that applies |
|---|---|---|
| ActiveRecord record | Workflow input identifier (for example, an integer ID or UUID) | Pass the ID, not the full record; load the record inside an activity so each attempt reads current data |
| Background job arguments (ActiveJob) | Serializable workflow input | Keep arguments to plain values that round-trip through the payload converter; check the Ruby SDK docs for supported types |
| Current user | Explicit field in workflow input or activity input | Pass the user ID as data; do not rely on thread-local Rails globals such as Current inside workflow code |
| Tenant or request context | Workflow input field, or context propagated by an interceptor | Confirm in the Ruby SDK docs how context propagation works before choosing between explicit fields and interceptors |
| Current time and random values | Workflow API for time and randomness, or values computed in an activity | Keep Time.now, rand and similar calls out of workflow code, since replay must produce the same decisions |
| Rails credentials and environment secrets | Worker-side configuration read at worker startup or inside activities | Never place secrets in workflow inputs or event history; resolve them on the worker that runs the activity |
| Database transaction | Activity boundary | Do not wrap a workflow call in a transaction; commit database changes inside an activity and make it safe to retry |
| ActiveRecord callbacks and jobs enqueued from callbacks | Workflow start or signal from application code after commit | Start workflows after the transaction commits so the workflow never sees uncommitted state |
Securing the Rails to Temporal connection and payloads
A Rails application that starts Temporal workflows or runs workers is a client of the Temporal Service, and every job argument it sends crosses that connection and lands in workflow history. The controls below cover the transport, the caller identity, the admin sign-in and the payload contents, and they only protect you if they are configured together.
Mutual TLS between services
Self-hosted Temporal supports mTLS with separate settings for internode traffic (between Temporal's own services) and frontend traffic (where SDK clients and workers connect). Plan certificate issuance for the Rails web processes, Sidekiq-style job processes and Ruby workers as distinct client identities. Confirm the TLS configuration keys in the Ruby SDK documentation, since the client must present a certificate the frontend trusts.
Temporal security docsCredentials the server accepts
The Ruby client has to present credentials that match what the server is configured to verify, whether that is a client certificate or a JWT. A mismatch usually shows up as connection failures that look like network problems, so test the client against a non-production frontend before rolling out. Record which identity each Rails environment uses so you can revoke one without touching the others.
ClaimMapper and Authorizer
If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Configure a ClaimMapper to map JWT or certificate claims to namespace roles, and an Authorizer plugin to enforce them. Verify with a test client that a Rails identity without the right role is refused for the namespace it should not reach.
Authorization controlsOIDC sign-in for the Web UI
The Temporal Web UI can use OIDC single sign-on, so operators who inspect workflow histories, terminate executions or reset workflows sign in through your identity provider rather than a shared login. Map groups from the provider to the operator roles you defined. Confirm which provider settings your identity platform needs, and keep break-glass access documented and tested.
Payload encryption with a codec
Job arguments and results are stored in workflow history, so sensitive values such as account identifiers or personal data should be encrypted before they leave the Rails process. A custom codec encrypts payloads in the Ruby SDK, and a codec server lets the Web UI decode them for authorized users. Decide which fields to encrypt, who holds the keys, and how keys rotate, and confirm the codec hook names in the Ruby SDK documentation.
Payload encryption docsServices off the public internet
Temporal's deployment guidance says its services should run on hosts that are not reachable from the public internet, with network access limited to trusted internal networks. Place the Temporal Service and its databases on private subnets, allow the Rails and worker networks explicitly, and check the frontend port from outside the trusted range. Review this when Rails hosts move between clusters or regions.
Deployment guideFailures teams hit when Rails and Temporal first meet
This table pairs the failures teams most often see when a Rails app first talks to Temporal with their likely causes and the check to run before changing anything. Read each row as a starting point: confirm exact error messages against the Ruby SDK and the Temporal Server logs before acting. The main takeaway is that most first-week failures come from worker placement, network and TLS settings, or code loaded differently in development, and each has a direct check.
| Symptom | Likely cause | Fix and check to run |
|---|---|---|
| Workers never appear as polling on the task queue | The worker process was not started, points at the wrong namespace or address, or runs a task queue name that differs from the one the client starts workflows on | Confirm the worker process is running and logs its connection target. Compare the namespace and task queue name in the worker and the starter code, then check the task queue poller list in the Web UI or with the Temporal CLI. |
| Workflows stay in Running with no worker progress | No registered worker polls the queue the workflow or activity was scheduled on, or the workflow class or activity name is not registered in that worker | Check that every workflow and activity type named in the history is registered in a running worker. Review the event history for the last scheduled task and confirm which queue it was sent to. |
| Rails requests to Temporal fail on TLS | Client certificate, CA bundle or server name does not match the frontend settings, or Rails talks to the internode port instead of the frontend port | Compare the client TLS settings with the frontend mTLS configuration on the server. Test the connection outside Rails first, then confirm the certificate chain and server name against your security team's records. |
| Requests from Rails are rejected for authorization | An Authorizer or ClaimMapper is configured, and the credentials Rails sends do not map to a namespace role, or no Authorizer exists and the default allows everything | Decode the identity token or certificate the client presents and check its claims against the ClaimMapper rules. Confirm which Authorizer the server runs and record the result, since the default noopAuthorizer allows all requests. |
| Non-determinism errors after a workflow change | Workflow code changed command order, timers, activity names or branching while open executions were still running on the old history | Run replay tests against recorded histories from the affected workflow type before deploying. Use versioning or patching as the Ruby SDK documents for the change, and confirm the exact error text in the worker log. |
| Large payloads fail when passing job arguments | Rails passes full model objects, large hashes or file contents as workflow or activity arguments, exceeding payload size limits | Measure the serialized size of each argument. Pass identifiers and store large content in your own storage, then load it inside the activity. Check the server and SDK limit messages in the logs before changing any limit. |
| Rails reloader or autoloading breaks worker code in development | Zeitwerk reloads classes that workflow and activity code still references, or the worker loads the Rails app twice with different class objects | Keep the worker in its own process with a clear boot file, and confirm the Rails reloading behavior the Ruby SDK documents for workers. Restart the worker after code changes and check that the same class names resolve in both the Rails process and the worker. |
What buyers ask before hiring help with Temporal in Rails
What drives the cost and effort of moving a Rails app onto Temporal?
The main driver is how many background jobs you move and how tangled each one is with application state. Cost has three parts: design work to decide which jobs become workflows and which stay as plain jobs, build work to write the workflows, activities and worker setup in Ruby, and operations work to run the Temporal Service and workers after handover. Jobs that call many external systems, need retries with custom timing, or wait for human approval take longer than simple mail or cleanup jobs. Ask any partner for a quote built from a written job inventory, with each job marked as a workflow, an activity or a job to leave alone, and with the cost of testing and deployment listed separately.
How long does a first Temporal integration in Rails take, and what sets that timeline?
The timeline depends on the number of workflows, the number of external dependencies, how much existing Sidekiq or Active Job behavior must be matched, and how quickly your team can grant access and review changes. A first integration usually covers one bounded workflow family, a non-production environment and a production rollout plan, and it is scoped in writing before work starts. No general duration applies to every Rails codebase, so ask for a schedule tied to the agreed scope and list the points where your staff must respond, such as access approvals and staging sign-off.
What must our internal team provide before an outside partner starts?
Expect to provide four things. First, access to the Rails repository, staging environment, and the infrastructure where Temporal Server and workers will run. Second, a staging environment that mirrors production closely enough to test retries, timeouts and database connections. Third, a job inventory listing every Sidekiq or Active Job class, its queue, schedule, retry settings, owner, and the systems it touches. Fourth, a named on-call owner who can respond to worker alerts and approve production changes. Confirm with the partner which of these they need in writing before the statement of work is signed.
Can our team implement Temporal in Rails without outside help?
Yes, a team with Ruby and Rails experience can build this internally, provided it has time to learn the Temporal determinism rules, plan for worker operations and review the Ruby SDK documentation carefully. The harder parts are usually not the first workflow but the later ones: safe code changes to running workflows, testing that catches non-deterministic changes, and running workers and the server reliably. Outside help is most useful for design reviews, a first production workflow, and a handover with runbooks. Decide early which of these your team will own after go-live.
Should we self-host Temporal or use Temporal Cloud for a Rails application?
The choice depends on where your data may live, who runs the infrastructure, and what your security and compliance reviews require. Self-hosted Temporal runs in infrastructure you control and needs you to operate the server, its persistence database and visibility store, and upgrades. Temporal Cloud is a managed service from Temporal Technologies, and its pay-as-you-go pricing starts at 50 US dollars per million actions, with storage charged per GB-hour, according to the Temporal pricing page. Compare the recurring action and storage volume your workflows will generate against your internal operations cost, and confirm the data residency and access terms with Temporal before deciding.
Do all our Sidekiq or Active Job jobs have to move to Temporal at once?
No. Most teams move a bounded set of jobs first, usually the ones that need durable retries, long waits or multi-step coordination, and leave simple, short, idempotent jobs on Sidekiq or Active Job. Both systems can run side by side during the transition, with clear ownership for each job type. Moving everything at once raises risk because it changes many failure paths together. Ask any partner to propose a phased list in the job inventory, with a rollback path for each phase and a date-independent exit condition for each step.
Where should Temporal workers run next to a Rails app, and what must we check?
Workers are separate processes that poll Temporal task queues, so they usually run as their own deployment next to the Rails app, not inside web processes. Check that worker hosts can reach the Temporal frontend and the database connections they need, and that services are not reachable from the public internet, as the Temporal deployment documentation recommends. Confirm how workers shut down during deploys, how secrets are passed, and which metrics and alerts your on-call team will watch before any production workflow goes live.
How DeployOpen scopes, delivers and supports the Rails integration
DeployOpen approaches Temporal in Ruby on Rails as a written, fixed-scope engagement covering the Ruby SDK, the Rails integration, worker placement and the move of selected background jobs. Work runs inside your own infrastructure, and the scope, deliverables and timeline are agreed in writing before work starts.
How we scope
- Inventory the Rails services, background jobs and workflows that would move onto Temporal, with owners for each.
- Confirm the self-hosted or Temporal Cloud decision and the infrastructure that will host the Temporal Service and workers.
- Agree in writing which jobs migrate, which stay on existing queues, and what cutover and rollback look like.
How we build
- Configure the Rails integration, worker processes and task queues in environments you control, with code delivered to your repositories.
- Design workflow and activity boundaries, retry policies and idempotency for each migrated job before implementation.
- Test workflow code with replay checks and integration tests on the Ruby SDK before any change reaches production.
How we hand over
- Document worker deployment, configuration keys, namespaces, secrets handling and the versioning approach used for workflow changes.
- Walk your platform and Rails teams through runbooks for deploying workers, draining them and investigating failed executions.
- Deliver operational evidence such as access settings, logging configuration and test results for your security and compliance reviewers.
How we support
- Support is available as a retainer for Rails upgrades, Temporal Server upgrades and new workflows added after handover.
- Retainers can cover upgrade planning and retesting of workflow code against new SDK and server releases.
- Ask for the support scope, response expectations and upgrade responsibilities to be written into the quote.

