Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

FreeAgent Engineering 5 min read How-to mediumAdept

Persisting nested form attribute indexes through Turbo updates

When a Turbo Stream replaces part of a Rails nested form, the replacement fields must keep the same attribute index as their siblings, which can be passed via the form builder's `index` property as a URL parameter and hidden field. This breaks for rows added client-side with JavaScript templates and timestamp indexes, because the form builder never learns the index and links carry a blank value. FreeAgent fixed it by moving the "Add Another" behaviour to a server-rendered Turbo Stream that sets a timestamp index on `fields_for`, removing the client-side templating duplication entirely.

Assumes: Rails form helpersHotwire Turbo Streamsnested attributes in Rails

Related posts

  • How DatoCMS solved tag invalidation with Turso

    Turso easyNovice

    DatoCMS's Content Delivery API attaches cache tags to every response and sends invalidated tags to the frontend via webhook, but Next.js limits a cache item to 64 tags. To work around it, the DatoCMS Next.js starter stores query-identifier/cache-tag pairs in a single two-column Turso table and tags each page with only the query ID (a SHA1 digest). On invalidation, it looks up the affected queries, invalidates them, and deletes their rows. The writeup mainly promotes the starter and Turso's free plan, with only a brief sketch of the mechanism.

  • Changing a polymorphic_type in Rails

    Shopify Engineering mediumAdept

    Rails stores the parent's class name in a polymorphic association's type column, so moving models into a new namespace (e.g. Car to Garage::Car) leaves mixed values like "Car" and "Garage::Car" and breaks lookups in both directions. Shopify's Payment Flexibility team decoupled the database from class names by overriding polymorphic_name to write arbitrary strings such as "car", then used an unscoped association scope to read both old and new values during the transition. After a backfill of existing rows, the temporary scope is removed and future renames only require updating a class-mapping hash. The approach adds complexity and is mainly worth it when module and class names are expected to change.

  • Incident 2023-12-04: Data leak and loss in some free tier databases

    Turso mediumAdept

    A migration bug introduced on November 20 left 0.07% of Turso free-tier databases with an empty backup identifier, so they all pointed at a shared S3 prefix (s3://bucket//) instead of per-database paths. When scale-to-zero databases on fly.io couldn't be resumed and were recreated from backup, they restored from this shared location, leaking data across tenants. The fix re-ran the migration and restored each affected database from its correct December 1 backup, discarding later writes. Remediation includes control- and data-plane checks that backups match their database, stricter allowed configurations with self-healing, safer migrations and better security reporting channels.

  • You can now migrate your existing databases to AWS

    Turso mediumAdept

    Turso paid-plan users can move database groups from Fly.io to AWS with new `turso group aws-migration info/start/abort` CLI commands; free-tier users have already been migrated. Migration is irreversible, keeps databases read-only with writes paused (usually under a minute, longer for 1 GB+), and drops features such as cross-database ATTACH, multi-DB schemas, server-side WebSockets, edge replicas and some extensions like sqlite-vss. Embedded replicas need their local files deleted and re-synced because the on-disk format and protocol differ. For remote writes, use execute/run paths without RETURNING, keep transactions short, avoid cached write statements, and reconnect and retry on stream errors, with SDK-specific guidance for JS, Python and Go or a switch to the new Turso Sync push-based packages.

  • Introducing Bobbin

    Tangled mediumAdept

    Bobbin is a read-only, API-only AppView for Tangled that serves the sh.tangled.* atproto lexicons over XRPC while holding everything in RAM. It rebuilds its index from scratch on every restart by consuming a Hydrant aggregator stream from cursor 0, so reconciling with the true PDS-held data takes nothing more than a restart. Backfill of the whole Tangled dataset takes about 30-90 seconds with a warm Hydrant, or up to 20 minutes cold, and compression brought memory use to roughly 100-200MB. During warm-up it answers point lookups through the Slingshot edge cache, proxies Knot requests directly to knots, and is designed so one Hydrant can feed hundreds of Bobbin instances, with hourly snapshots or disk offload as possible future changes.

The quest for software engineering knowledge.

Look:
Layout: