Developer tips Pair Programming Tips for Remote Developers Remote pairing has a bad reputation earned mostly by bad sessions: three hours on a call, one person driving the whole time, the other watching a laggy screen share and drifting into Slack.
Rails-code Run Raw Sql In Rails And Map The Results To A Ruby Struct Reporting queries with window functions, CTEs, and cross-table aggregates are painful to express in ActiveRecord and produce untyped hashes when you drop to SQL. Mapping the rows into a Struct gives you named
Rails-code Validate Uniqueness Of A Combination Of Two Columns In Rails A user can only be a member of an organisation once. A product can only have one price per currency. The rule is not “this column is unique” but “this pair is unique”,
Rails Request Specs vs Controller Specs — What to Test at Each Layer Controller specs let you call an action directly and assert on assigned instance variables. They’re fast, they’re focused, and the Rails team has been steering people away from them for years. The reason
Ruby-code Parse A Csv String Into An Array Of Hashes With Headers In Ruby Uploaded spreadsheets and API exports arrive as CSV strings. Converting them into an array of hashes keyed by header name makes the rest of the code readable — row[:email] instead of row[3].
Ruby 3 Decorators in Ruby — Delegation Patterns That Don't Fall Apart You want to add display logic to a model without putting it on the model. So you reach for SimpleDelegator, wrap the object, add three methods, and it works — until something calls
Developer tips Writing Error Messages That Help — What to Include and What to Skip Invalid configuration. That’s the whole message. Somewhere in a 300-line YAML file there’s a problem, and the program knows exactly which key, which line, and what it expected — it just chose not
Rails-code Batch Process A Large Activerecord Query Without Memory Bloat Order.all.each loads every row into memory before iterating. At forty thousand rows that is slow; at four million it is an out-of-memory kill. Rails has three batching methods and they solve slightly different
Rails Bulletproofing Rails Migrations — Zero-Downtime Strategies for Large Tables rails db:migrate on a forty-row development database takes eleven milliseconds. The same migration against a forty-million-row production table takes an ACCESS EXCLUSIVE lock, queues every query behind it, exhausts the connection pool, and
Developer tips How to Use GitHub CLI for PRs and Issues Without Touching the Browser Push a branch, switch to the browser, wait for it to load, click “Compare & pull request”, retype the description you already wrote in your commit message, pick reviewers from a dropdown, submit.
Ruby-code Count Unique Values Across Nested Arrays In Ruby Without Duplicates Tags across a set of posts, permissions across a set of roles, skills across a team — the data arrives as an array of arrays and you need the distinct total, or the
Ruby 3 ObjectSpace and Memory Profiling — Finding Leaks Before Production Does A Puma worker starts at 180MB and sits at 1.4GB by the end of the day. Restarting fixes it, so someone adds a memory-based worker killer and the problem becomes invisible rather than
Rails with_options — DRY Validations and Routes Without the Abstraction Tax Six validations in a row, each ending with the same if: :submitted?. Four routes sharing the same constraint. Three associations with identical dependent: :destroy, inverse_of: options. The repetition is noise, but the usual
Developer tips Semantic Versioning in Practice — When to Bump Major, Minor, or Patch Everyone knows MAJOR.MINOR.PATCH. The spec fits on one page and takes four minutes to read. And yet every library maintainer has shipped a patch release that broke someone, because the hard part was
Rails-code Return Clean Consistent Json Errors From A Rails Api Controller An API that returns a validation error one shape, a 404 another shape, and an HTML error page for anything unhandled forces every client to write three parsers. One rescue block in the