Developer tips Using .gitignore Effectively for Rails Projects Somebody commits .DS_Store, someone else adds *.DS_Store to the project’s .gitignore, and three months later there are eleven personal editor entries in a file that’s supposed to describe the project. Meanwhile config/master.key is
Rails-code Generate A Signed Expiring Url For An Active Storage Attachment Private files — invoices, contracts, medical records — should not be served from a permanent public URL. Active Storage generates signed URLs that expire, so a leaked link stops working.
Rails Rails System Tests With Capybara — Setup, Speed, and Staying Sane System tests are the ones that catch the bugs nobody else does — the form that submits fine but whose success message never renders, the Turbo Frame that silently swallows a redirect. They’re
Developer tips Terminal Shortcuts Every Developer Should Know You mistype a flag near the start of a long command and hold the left arrow for four seconds to get there. You retype a path you used two commands ago. You press
Rails-code Upsert A Record In Rails Using Upsert_all With Conflict Resolution Syncing from an external system means “create it if it is new, update it if it exists” for thousands of rows. Doing that with find_or_initialize_by in a loop is two queries per record;
Ruby 3 Writing Fast Ruby — Benchmarking with benchmark-ips and Reading the Results Honestly Someone on the team claims map.compact is faster than filter_map. Someone else says the opposite. Both have benchmarks. Both benchmarks are wrong, in different ways — one measured a hundred iterations on a
Developer tips Pry Power User — ls, cd, show-source, and the Commands That Replace Grep Most people install Pry, use it as a slightly nicer IRB with a binding.pry breakpoint, and never touch the rest. That’s a shame, because the interesting part isn’t the REPL — it’s that
Ruby-code Remove Duplicate Hashes From An Array By A Specific Key In Ruby uniq on an array of hashes compares whole hashes, so two records that share an id but differ in any other field both survive. Deduplicating by one key — an id, an email,
Rails Rack Middleware From Scratch — What Lives Between the Internet and Your Rails App Before a request reaches your controller it passes through roughly twenty pieces of code you didn’t write. Session handling, cookie parsing, parameter decoding, flash messages, exception rendering — all of it is Rack
Developer tips Editor Setup for Rails — The Extensions and Keybindings Worth Keeping There’s a genre of blog post that lists forty editor extensions. You install all forty, your editor takes twelve seconds to start, three of them fight over formatting, and you uninstall the lot
Rails-code Find Records Where A Jsonb Column Contains A Specific Key In Rails Settings bags, API payloads, and feature-flag hashes all end up in a jsonb column, and eventually you need to query them — every account with a particular preference set, every webhook whose payload
Developer tips Shell Aliases and Functions Every Rails Dev Should Have You type bundle exec rspec spec/models/ maybe forty times a day. Over a year that’s a few hours of pure keystrokes, and more importantly it’s a few hours of tiny frictions that discourage
Ruby-code Flatten A Hash Of Arrays Into A Flat Array Of Hashes In Ruby Grouped data — { "ruby" => [post1, post2], "rails" => [post3] } — often needs to be turned back into a flat list where each item carries its group. It is the inverse
Ruby 3 TracePoint in Practice — Instrument Your Code Without Reaching for a Gem Something in a Rails boot sequence is defining a method you can’t find. A query is being issued from a code path you can’t identify. An exception is swallowed six layers down and
Rails Database Indexing for Rails Devs — Composite, Partial, and What EXPLAIN Is Telling You Rails makes it easy to write a query and hard to see what it costs. add_index on every foreign key is the standard advice and it’s a decent floor, but it doesn’t help