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.
Configuring Rails Environments Despite its strong opinions and powerful conventions, Rails is a highly flexible and configurable framework. If you don’t like something, there’s almost certainly a way to change it. This article provides a brief overview of configuring Rails applications and environments.
Turbo Streams: How They Work and Differ From Turbo Frames No, you don’t need WebSockets to use Turbo Streams. You can simply use them to deliver multiple page updates with a single HTML response. This article teaches the basics of Turbo Streams to build a SPA without writing a single line of JavaScript. No Rails needed, either!
A Brief Introduction to Hotwire Hotwire, which stands for HTML Over the Wire, provides a different way to build modern web applications without using too much JavaScript. This article provides a quick introduction to Hotwire and its component frameworks, such as Turbo Drive, Frames, and Streams.