Sign up for my newsletter

Let's learn to become better developers.

Understanding the Match Method in Rails Router

In this post, we will learn about the match method, which forms the core of the Rails router. We'll also explore how the match method works behind the scenes. Once you really understand the match method and its options, the rest of the routing methods and shorthands become very easy to understand.

July 15, 2024

Understanding the Match Method in Rails Router

How to Override the Named Route Parameter ID in Rails

Rails generates URLs using the to_param value on models by default, which returns the id. By overriding to_param and adjusting your route segment (for example to :slug), you can replace the id with any meaningful value like a slug in your URLs.

July 12, 2024

How to Override the Named Route Parameter ID in Rails

Understanding Named Routes in Rails

In this post, we'll learn how named routes work in Rails. You can name a route by passing the as option. The router will create two helper methods based on this name to generate the URLs for the route.

July 10, 2024

Understanding Named Routes in Rails

How to Add a root Route in Rails

This post shows how to configure a root route for your application. This is the page your visitors will encounter the first time they visit your Rails app.

July 09, 2024

How to Add a root Route in Rails

How to Redirect Incoming HTTP Requests Using Rails Router

This post shows how you can redirect incoming HTTP requests using the Rails router with the help of the redirect() method.

July 02, 2024

How to Redirect Incoming HTTP Requests Using Rails Router

How to Access Raw POST Data in Rails

This post shows how you can access the raw, unaltered request body using a 20-year old method in the Rails framework (from the founder of Shopify). The `raw_post` method reads the request body, and is useful for web services or API controllers that need to directly work with raw requests.

June 26, 2024

How to Access Raw POST Data in Rails

Rails Router: Dynamic Segments and Query Strings

Rails routes aren’t just static paths. Dynamic segments let you capture values directly from the URL, while query strings handle optional parameters. This post explains how Rails parses both, when to use each, and common pitfalls to avoid.

June 22, 2024

Rails Router: Dynamic Segments and Query Strings

Polymorphic Associations in Rails: Why, What, and How

Polymorphic associations in Rails allow a single model to belong to multiple models. This article covers them in-depth. We'll start with understanding the concept of polymorphism, learn what a polymorphic association is, why we need them, how they work, and how to use them in your Rails application.

June 16, 2024

Polymorphic Associations in Rails: Why, What, and How

A Brief Overview of the Rails Routing Config File

The Rails routing file defines how incoming requests map to controllers and actions. This post breaks down config/routes.rb, explains resourceful routes, nesting, and constraints, and shows how small routing choices affect clarity, URLs, and long-term maintainability.

June 14, 2024

A Brief Overview of the Rails Routing Config File

Introduction to the Routing System in Rails

The Rails router sits at the front of every request, deciding which controller and action should handle it.

June 09, 2024

Introduction to the Routing System in Rails