RSSAmplifier

Blog

Prateek Codes - Building Scalable Backend Systems

Learn how to build scalable backend systems with Ruby on Rails, PostgreSQL optimization, database scaling, and practical engineering insights from real-world production experiences.

prateekcodes.comRSS feed ↗10 posts

Latest posts

Multi-hop delegation for AI agents: porting OAuth's on-behalf-of pattern into MCP topologies

Most AI agent deployments hit an awkward authentication problem inherited from web auth. A user authenticates. The user invokes an agent. The agent calls a tool. The tool calls another tool. By the time the request reaches the third service down, the identity of the original principal has either been lost, forged, or smuggled forward as a bearer credential that the agent could just as easily…

Stop Pasting Schema Into Your AI: Connect PostgreSQL Directly with MCP

Agentic coding tools have gotten good at reading your codebase. Claude Code will find your schema.rb , Cursor will pick up your Prisma schema, and most tools know how to navigate ORM-based projects well enough to understand your data model structurally. What they can’t do is reason about your actual data - and that gap matters more than most developers realize. When you ask an AI to help design a…

Rails 8.2 adds this_week?, this_month?, and this_year? to Date and Time

ActiveSupport already has today? , yesterday? , and tomorrow? on Date and Time . Rails 8.2 adds the next logical set: this_week? , this_month? , and this_year? . Before Checking whether a date falls within the current week, month, or year required range comparisons: # Is this order from the current week? order.placed_at.between?(Time.current.beginning_of_week, Time.current.end_of_week) # Is this…

Read-only database MCPs as a scoped-delegation pattern: applying IAM primitives to AI agents

AI agents are useful in proportion to the context they can read. That is the productive observation. The unproductive one, which follows about thirty seconds later, is that giving an agent the context it wants usually means giving it broad access to production data. Most teams reach for one of three approaches: hand the agent a database credential, filter the agent’s behavior at the prompt layer…

Rails 8.2 lets retry_on read the error when calculating wait time

Active Job’s retry_on accepts a wait: proc for custom backoff logic. Before Rails 8.2, that proc only received the execution count. When a remote API returns a Retry-After header, there was no way to use that value inside the proc. Rails 8.2 fixes this by passing the exception as a second argument. Before The wait: proc only knew how many times the job had been attempted: class PaymentSyncJob <…

Ruby::Box Practical Guide: Use Cases and Integration Patterns (Part 2)

In Part 1 , we covered what Ruby::Box is and how it provides namespace isolation. Now let’s explore practical patterns for integrating it into real applications. Use Case: Plugin Systems Plugin systems benefit significantly from Ruby::Box . Each plugin runs in its own isolated environment, preventing plugins from interfering with each other or the host application. class PluginManager def…

Ruby 4.0 Introduces Ruby::Box for In-Process Isolation (Part 1)

Ruby 4.0 introduces Ruby::Box , a feature that provides isolated namespaces within a single Ruby process. This solves a long-standing problem: monkey patches and global modifications from one gem affecting all other code in your application. The Problem with Shared Namespaces When you load a gem that modifies core classes, those changes affect everything in your Ruby process: # Gem A adds a…

Rails 8.2 makes enqueue_after_transaction_commit the default

Rails 7.2 introduced enqueue_after_transaction_commit to prevent race conditions when jobs are enqueued inside database transactions. However, it required explicit opt-in. Rails 8.2 flips the default. Jobs are now automatically deferred until after the transaction commits. The Problem with Opt-In With the opt-in approach in Rails 7.2, teams had to remember to enable the feature:…

Rails 7.2 adds enqueue_after_transaction_commit to prevent job race conditions

Scheduling background jobs inside database transactions is a common anti-pattern which is a source of several production bugs in Rails applications. The job can execute before the transaction commits, leading to RecordNotFound or ActiveJob::DeserializationError because the data it needs does not exist yet. Or worse, the job could run assuming the txn would commit, but it rolls back at a later…

Rails 8.2 introduces Rails.app.creds for unified credential management

Applications often store secrets in both environment variables and encrypted credential files. Migrating between these storage methods or using both simultaneously has traditionally required code changes. Rails 8.2 solves this with Rails.app.creds , a unified API that checks ENV first, then falls back to encrypted credentials. Before Managing credentials from multiple sources meant mixing…