Simplifying My Blogging Workflow with Ruby This is the 100th post on this blog 🎉 I wanted to share how a simple Ruby script simplified my blogging workflow and dramatically increased the number of posts I write on my various blogs.
Did You Know that You Can Catch and Throw Stuff in Ruby? Unlike traditional programming languages, Ruby's throw and catch are not used to raise and catch exceptions. Instead, they let you escape from deeply nested control flows. This post shows how `throw-catch` works in Ruby with practical, real-world examples, including their usage by the Warden gem.
Various Ways to Run Shell Commands in Ruby Ruby provides multiple ways to conveniently execute external processes from the code. In this article, we'll learn all the ways you can run shell commands in Ruby and also consider various circumstances under which you'd choose one over the other.
Ruby's Switch Statement is More Flexible Than You Thought Ruby's switch statement is very versatile and flexible, especially due to the dynamic nature of Ruby. In this post, we'll see how you can use it in various ways. We'll also learn why it works the way it works. Hint: it uses the `===` operator (method) under the hood.
Can You Spot the Error? I recently encountered this error and in the process of debugging, learned some useful stuff about `self` and how assignment works in Ruby. See if you can figure it out yourself. Can you spot the error in this simple Ruby snippet?
A List of Books to Learn Programming with Ruby and Rails This post provides a curated list of books to learn to code in Ruby and build web applications with Rails. It also gives a step-by-step path you can follow to learn enough before moving to the next step. If you ever wanted to learn to program but didn't know where to start, this post is for you.
How to Access Hash Values with Methods Using OrderedOptions Have you ever wanted to create a hash where you could access the values like methods on an object? The OrderedOptions class in Rails lets you do just that. This post shows you how. We'll also explore how Rails implements this feature using Ruby's metaprogramming features.
The Definitive Guide to Rack for Rails Developers The word Rack actually refers to two things: a protocol and a gem. This article explains pretty much everything you need to know about Rack as a Rails developer. We will start by understanding the problem Rack solves and move to more advanced concepts like middleware and the Rack DSL. This article is for Members only
Readonly Attributes in Rails In this article, we'll learn how to mark certain attributes as readonly on your active record models, to prevent them from any future updates after the record is created and saved to the database. We'll also learn how Rails implements this feature behind the scenes.
Sessions in Rails: Everything You Need to Know In this post, we’ll learn about Rails sessions, including what is a session, why we need them, and why they're so important. I’ll also take you behind the scenes and show you how Rails implements sessions and where the `session` method actually comes from. Hint: it’s not in the Rails codebase.
Understanding the Attribute Assignment API in Rails In this post, we will explore the `AttributeAssignment` module in Rails, which allows you to set an object's attributes by passing in a hash, a feature commonly used by Active Record models. We'll also learn a little metaprogramming along the way.
Progressive Application Development with Hotwire This is the day when you fall in love with Hotwire. We're going to build a simple counter. But we're not going to build it once and be done with it. Instead, we'll build and progressively enhance it with all three frameworks in Hotwire: Turbo Drive, Turbo Frames, and Turbo Streams.