Prevent Logging Sensitive Data with Rails Parameter Filters This article explains why you shouldn't log confidential or user-identifiable information and how to filter it using parameter filtering in Rails. We'll also do a deep dive into the Rails source code to learn exactly how Rails implements parameter filters.
💬 Understanding How Rails Environments Work This post covers the basics of environments in Rails, including what they are, how they work and why they're so important. We'll also take a look behind the scenes and dive into the Rails source code to learn exactly how they're implemented, exploring a few interesting "inquiry" classes in Rails.
Learn to Program Ruby with Me Any topic, no matter how basic, can be made much more interesting if you dig deep enough, and we can always improve, grow, and extract more out of our education. This post announces a new tutorial on this blog where we'll learn to program in Ruby from the absolute basics. Hope you join me.
How to Process a Turbo Stream Response in JavaScript using Stimulus It’s common to make HTTP fetch request to get some data from the server. It’s also convenient to update the HTML via Turbo Stream responses. What if you could combine the benefits of them both? This post shows you how to process Stream responses in JavaScript, without mucking around with the DOM.
The Rails Config File You must have used a `~/.bashrc` or `~/.zshrc` file to configure your environment. Did you know Ruby on Rails has a `~/.railsrc` file that configures your Rails applications? Not only that, it lets you pre-configure the gems you want in all your Rails applications. This post shows how it works.
Why You Need Strong Parameters in Rails In 2012, GitHub was compromised by Mass Assignment vulnerability. A GitHub user used mass assignment that gave him administrator privileges to none other than the Ruby on Rails project. In this post, I will explain this vulnerability and how you can use the Rails strong parameters API to address it.
See Other After Destroy This post explains why you should use the 303 See Other HTTP status after destroying a resource, instead of using 302 Redirect.
How to Remove Whitespace from a String in Ruby Often, you want to sanitize a string variable by removing all leading and trailing whitespaces around it. This is usually needed when you receive the string input from a user or an external source. This post shows you how.
Annual Blog Review: 2023 Every year, I do a personal annual review. This year, I thought why not do the same for my blog, since it has become such an integral part of my life, both personal and professional. This post contains some of the highlights and a list of all the articles I wrote in 2023.
Enqueue Multiple Jobs Together with perform_all_later in Rails Are you still looping over the list of jobs to enqueue them individually? This post explores the new `perform_all_later` method in Rails, which was introduced in Rails 7.1 and lets you enqueue multiple jobs together to reduce the round-trip to the job backend, like Redis or the database.
Nested Modules in Ruby There are two different ways to define nested modules in Ruby. This post explains them both along with the differences between them and how to decide which one to use. We will also learn about the `Module.nesting` method, which returns the list of nesting for a module.
How to Read a File in Ruby Reading a file is a simple yet common programming task that can be accomplished in a few different ways in Ruby. In this post, we're going to cover the basics of reading files in Ruby, including few different ways to open and read files, both in-memory and via streaming.