FirstDEV blog
  • Home
  • Ruby
  • Ruby On Rails
  • Tips
  • Solutions
  • About
Subscribe
cdrrazan

Rajan Bhattarai

Full Stack Software Developer! 💻 🏡 Grad. Student, MCS. 🎓 Class of '23. GitKraken Ambassador 🇳🇵 2021/22. Works with Ruby / Rails. Photography when no coding. Also tweets a lot at TW / @cdrrazan!

195 posts •
Developer tips

How to Navigate an Unfamiliar Open Source Codebase Fast

A gem is misbehaving and the docs don’t cover your case. You clone it, open the source, and there are 340 files. The instinct is to start at the top of the directory

Rajan Bhattarai Rajan Bhattarai 10 min read
Rails-code

Soft Delete Records In Rails Without A Gem Using Discarded_at

Some records should disappear from the application without leaving the database — orders referenced by invoices, users referenced by audit logs. A nullable timestamp column and a default scope gives you soft deletion

Rajan Bhattarai Rajan Bhattarai 1 min read
Rails

Turbo Native — Wrapping Your Rails App in an iOS and Android Shell

A native app is three codebases: the web app, the iOS app, and the Android app, each reimplementing the same screens and drifting apart. Turbo Native takes a different position — your Rails

Rajan Bhattarai Rajan Bhattarai 11 min read
Developer tips

Writing Changelogs That Developers Actually Read

Most changelogs are a dump of commit subjects. “Merge pull request #412 from feature/fix-thing”, “wip”, “address review comments”. Nobody reads them, so nobody maintains them, so they get worse — and the one

Rajan Bhattarai Rajan Bhattarai 11 min read
Rails-code

Add A Custom Computed Column To An Activeadmin Index Page

The default ActiveAdmin index lists raw columns. Real admin screens need derived values — a total from associated rows, a status badge, a link to a related record — and the column block

Rajan Bhattarai Rajan Bhattarai 2 min read
Ruby 3

Frozen String Literals in Production — Real Wins and the Gotchas Nobody Mentions

The # frozen_string_literal: true magic comment sits at the top of nearly every file in a modern Ruby codebase, added by RuboCop, accepted without much thought. It’s a genuine optimization — measurably fewer

Rajan Bhattarai Rajan Bhattarai 11 min read
Developer tips

The Pull Request Description Nobody Writes (But Everyone Needs to Read)

Most pull request descriptions say some version of “fixes the bug.” The diff is four hundred lines across eleven files. Your reviewer opens it, has no idea what problem you were solving or

Rajan Bhattarai Rajan Bhattarai 11 min read
Rails-code

Test Action Mailer Content With Rspec Matchers In Rails

Mailers break quietly — a renamed method in a template, a missing interpolation, a recipient list that silently resolves to nil. None of it surfaces until a customer says they never got the

Rajan Bhattarai Rajan Bhattarai 2 min read
Rails

counter_cache and touch — Derived Data in Rails Without the Extra Query

An index page listing fifty posts, each showing a comment count, issues fifty-one queries. The fix is well known — counter_cache — and it’s usually applied incorrectly, either by forgetting the backfill, by

Rajan Bhattarai Rajan Bhattarai 11 min read
Developer tips

Async Code Review — How to Collaborate Without Blocking Each Other

You open a PR at 4pm Kathmandu time. Your reviewer is asleep in Lisbon. They review at 9am theirs, leave four questions, and go into meetings. You answer at 6pm yours. They respond

Rajan Bhattarai Rajan Bhattarai 11 min read
Rails-code

Serialize Query Params Back Into A Url String In Rails

Filter forms, pagination links, and sort toggles all need to rebuild the current URL with one parameter changed and the rest preserved. Doing it with string concatenation breaks on the first array parameter

Rajan Bhattarai Rajan Bhattarai 1 min read
Ruby-code

Truncate A String At A Word Boundary In Ruby Without Cutting Mid Word

Cutting a string at a fixed character count produces things like “The quick brown fo…”. Truncating at the last whole word before the limit reads properly and is what you want for previews,

Rajan Bhattarai Rajan Bhattarai 1 min read
Ruby-code

Extract Unique Values From An Array Of Hashes By A Key In Ruby

You have a list of records and you want every distinct value of one field — all the account ids in a batch, every category present in a result set, the set of

Rajan Bhattarai Rajan Bhattarai 2 min read
Ruby 3

Ruby's Object Model — Eigenclasses, Method Lookup, and What super Really Does

You can write Ruby for years without knowing what an eigenclass is. Then one day a gem defines a method you can’t find with grep, super calls something you didn’t expect, and define_method

Rajan Bhattarai Rajan Bhattarai 11 min read
Rails

ActiveRecord::Store — Structured Data in One Column Without a Migration Per Field

Some data doesn’t deserve a column. User interface preferences, per-account feature toggles, the last three filters someone applied to a report — attributes that are read constantly, queried almost never, and change shape

Rajan Bhattarai Rajan Bhattarai 10 min read
« Newer Posts Page 4 of 13 Older Posts »
FirstDEV blog © 2026
Proudly published with Jekyll & using Jasper2
Latest Posts Twitter
FirstDEV blog

Check viewARU - Brand Newsletter!

Newsletter to DEVs by DEVs - boost your Personal Brand & career! 🚀