- RailsNotes Newsletter
- Posts
- The RailsNotes Newsletter 🟥 ISSUE #29
The RailsNotes Newsletter 🟥 ISSUE #29
🟥 ISSUE #29 (VS Code rdbg extension, custom .irbrc, Rails console tips)
By the end of this week’s newsletter (and given the last one on a decent VS Code setup), this is how I expect you to feel next time you do some Ruby on Rails programming 😅
AI won’t take your job, but a person using AI might. That’s why 500,000+ professionals read The Rundown – the free newsletter that keeps you updated on the latest AI news and teaches you how to apply it in just 5 minutes a day.
Welcome to The RailsNotes Newsletter — Issue #29!
Hey! Welcome back! (and hello 👋 to all the new people!)
This week, we’re diving into an article I recently published on setting up the rdbg VS Code extension for Rails debugging. Once set up, you can debug your Ruby on Rails apps and specs within VS Code’s “Run and Debug” menu. It’s super handy and takes 5 minutes to set up!
I’ve also included some articles about customizing your IRB prompt with a .irbrc
file — it’s a simple, flexible way to customize your prompt. Some people seem to go pretty hard on customizing everything; I typically use the vanilla IRB console, but at work, we’ve got it set up to display the current Rails environment, and highlight itself red if you’re in a production console.
I hope you enjoy! Let’s dive in 👇️
~ ✨ FEATURED ARTICLE ✨ ~
Your face when you easily find the bug you were looking for with a quick ‘debugger’, after failing with ‘puts’ for 2 hours.
In the previous newsletter’s “Handy Tip”, I raced through an explanation on connecting the Ruby debugger
directly to VS Code. I’ve been debugging like that ever since, and I found it so useful that I decided to turn it into a full article!
This short article shows you how to use VS Code’s “Run and Debug” panel to connect to a live debugger
session, via the VS Code rdbg extension.
It’s great, works well, and takes 5 minutes to set up! Highly recommend giving it a go — if you hate it and want to switch back, it’s as easy as unsettling an environment variable, and uninstalling the extension.
Check it out!
~ MORE ARTICLES ~
A short and sweet article about customizing your Ruby/Rails environments with custom .rc
files — my favourite is the .irbrc
file, which lets you customize IRB in your Rails console.
If you’re interested in digging deeper into the .irbrc
, you can also check out Customizing the Rails Console — it adds customization to a console.rb
script, but you can also place it in .irbrc
Awesome Print is a cute little gem that pretty-prints your console output — hashes print symmetrically, nested data structures get indented nicely, and methods print out with their args and datatypes.
It’s super neat and can integrate directly into your .irbrc
to automatically get enabled for any IRB session.
The difference between binding.pry
, byebug
and debugger
confused me for years! This article does a great job of breaking down the differences, including the history behind debugger/byebug and the new Ruby debug gem.
~ ⚒️ HANDY TIP ~
→ A super simple .irbrc
example
Here’s a tiny, super simple .irbrc
file is from this handy Mintbit article — it’s worth digging into some more and getting yours JustRightTM , but I thought it was cool how simple they are to get started.
Start by creating a .irbrc
file in the root of one of your Ruby on Rails apps, and add this to it —
require 'irb/completion'
class MyPrompt < IRB::Context::SimplePrompt
def prompt(*args)
"[my-app] #{super}"
end
end
IRB.conf[:PROMPT_MODE] = MyPrompt.new
Run the rails console
, and you’ll see that each line is prefixed with [my-app]
(so you don’t forget which app you’re using!).
[my-app] irb(main):001:0> a = "Hello, world!"
[my-app] irb(main):002:0> puts a
Hello, world!
=> nil
[my-app] irb(main):003:0>
This is a pretty contrived example; You could prefix your prompt instead with Rails.env
to remind yourself whether your in a development, test or production console.
~👀 BEHIND THE SCENES~
This is a private section 🔐 for readers with 2+ referrals!
I share behind-the-scenes updates on RailsNotes and RailsNotes UI (think traffic numbers, sales, upcoming updates etc.)
Want access? Learn about the ✨ referral program ✨ down below! 👇️
Once again — not much going on 😦 I’ve been pretty busy with life/work stuff so side-projects continue to fall by the wayside.
I experimented with creating my first Chrome Extension recently though which was fun (I even managed to get TailwindCSS loaded into it 🤣 ) but no major Ruby / Rails projects for now.
~ 🌯 WRAP UP ~
Thanks for reading! The quick wrap-up for this week is —
In less than 5 minutes, you can setup the VS Code rdbg extension to give you a much better debugging experience for Ruby on Rails.
It’s easy to customize your
.irbrc
file! You can include methods, gems and customizations into your IRB console, to personalize it and make yourself more productive.
Share the RailsNotes Newsletter!
Use your unique link below to refer new Ruby on Rails devs to this newsletter (and make me really happy!). I’ll reward you with coupon codes, access to a private section, and a free RailsNotes UI license key 👇️
[Refer 1] A small feature in the next newsletter (with a link to something you’re working on, or your socials)
[Refer 2] Permanent access to the behind-the-scenes section, above 👆️
[Refer 5] A $20 coupon for RailsNotes UI 📬️
[Refer 15] Free licence key for RailsNotes UI 🤑