Concerns in Ruby: Part 1: Concerning Concerns

I recently wrote a post for the Maxwell Engineering blog regarding best practices around using concerns (aka. modules or mix-ins) in Ruby. You can check out part one of the four-part series at the following link:

Concerns in Ruby: Part 1: Concerning Concerns

Enjoy!

Rails 7: The Missing Instructions

Sadly, I had a lot of difficulty getting Rails 7 with Turbo and Stimulus up and running. The Rails docs feel like they’re missing a few steps, so I wanted to document the commands I needed to run to get Rails 7 with the hotwire.dev tooling up and running.

Continue reading “Rails 7: The Missing Instructions”

Ruby Paper Cuts

I love programming in Ruby and (especially) the Ruby on Rails framework. That said, they both have some oddities and conventions that leave me scratching my head, making me wonder what such smart people are thinking, and questioning the very nature of reality…you know, much like an episode of a Disney+ or CW show.

Continue reading “Ruby Paper Cuts”

Understanding unless in Ruby

I don’t know about you, but Ruby’s unless has always been kind of hard for me to grok, but I’m realizing that’s because I’ve never seen a great use of it, esp. one that made me go, “Oh wow – yeah I’d definitely use unless there vs. an if statement or something else.”

However, the deeper I’ve gotten into Ruby the more I’ve noticed one place where unless really shines – guard statements. Consider the following:

def update_book_title(book, title)
  return unless book.present?
 
  book.update(title: title)
end

Now there’s a place I would definitely use unless over other control flow constructs. It’s succinct, easy to understand, and honestly a pleasure to both write and read.

Nice job Ruby! 🔴💎

Legacy Ruby Code

A programmer programmed in PHP. The code she wrote was legacy code as soon as her commits entered the git repo, and they provided gainful employment for many other programmers for years to come.

Another programmer programmed in Ruby. His code was also legacy code from its inception, yet his code prompted several developers to pivot to management careers and a complete application rewrite in Go.

Upon hearing of this, a wise programmer remarked:

How much better it is to work with Java written in PHP than Java written in Ruby!