Skip to content

SYSTEM Cited by 6 sources

Ruby on Rails

Ruby on Rails is the dominant Ruby web-application framework (David Heinemeier Hansson, 2004). Canonical MVC web framework with ActiveRecord ORM, convention-over-configuration defaults, and a large ecosystem of companion gems for background jobs (Sidekiq), feature flags (Flipper), testing (Minitest / RSpec / FactoryBot), and SAML auth (ruby-saml).

Why it matters here

PlanetScale's application-tier backend is a Rails monolith. Multiple Rails-specific engineering posts have surfaced on the wiki:

Rails is also the substrate most SidekiqMiddleware::* code lives in — client middleware runs inside Rails request processes (or console sessions or rake tasks), server middleware inside Sidekiq worker processes that boot the same Rails app.

Seen in

Seen in — ActiveRecord query-rewriter gems

  • sources/2026-04-21-planetscale-introducing-fastpage-faster-offset-pagination-for-rails-apps — Mike Coutermarsh's 2022 introduction of PlanetScale's fast_page gem. Rails is the substrate for the ORM-level SQL-rewriter gem pattern: a method added to ActiveRecord::Relation mechanically transforms a query chain into a more efficient equivalent — here, the deferred-join rewrite for deep-offset pagination. The post's canonical usage pattern is Rails-idiomatic method-chain composition: Post.all.order(created_at: :desc).limit(25).offset(100).fast_page. Cross-ecosystem companion: Hammerstone's Laravel fast-paginate gem implements the same rewrite for Eloquent. Both gems confirm the broader observation that the ORM-query-rewriter pattern is ecosystem-portable — the rewrite is SQL-level, the gem is just the ergonomic wrapper.

Seen in — multi-database config + automatic role switching

  • sources/2026-04-21-planetscale-introducing-planetscale-portals-read-only-regions — Taylor Barnett's PlanetScale Portals launch uses Rails' multiple-databases / automatic role switching as the canonical application-side integration for a read- write-split + regional read replica architecture. Three Rails-specific mechanisms are load-bearing in the post:

  • database.yml multi-connectionprimary (write connection) + primary_replica (read connection with replica: true). Rails treats primary_replica as a read-only sibling of primary for monitoring / migration purposes.

  • connected_to(role: :reading) do … end — explicit per-block routing for code that wants to force replica reads.
  • ActiveRecord::Middleware::DatabaseSelector with { delay: 2.seconds } — automatic role switching. Reads go to primary_replica by default; after any write, a session cookie pins the user's reads back to primary for 2 seconds, preserving read-your-writes.

The Rails invocation is the canonical framework-level shape of the patterns/session-cookie-for-read-your-writes pattern — see that pattern page for the full recipe and equivalents in Django / Laravel / plain-driver apps. Code acknowledgment to Mike Coutermarsh (same PlanetScale-Rails engineer voice as the FastPage / SQLCommenter / self-healing- Sidekiq posts).

Last updated · 378 distilled / 1,213 read