Skip to content
Write Software, Well
  • Services
  • Books
  • Archive
  • About
Sign in Subscribe
Serving Static Files with Reverse Proxy using X-Sendfile

Serving Large Files in Rails with a Reverse Proxy Server

If your Rails app deals with large files, let a reverse proxy like Nginx or Thruster serve them. In this post, we'll learn how X-Accel-Redirect (or X-Sendfile) header hands off file delivery to Nginx. We'll also read Thruster’s source code to learn how this pattern is implemented at the proxy level.

12 min read

Featured

From a Lorry Driver to Ruby on Rails Developer at 38

From a Lorry Driver to Ruby on Rails Developer at 38

Interview 11 min read
Sustainable Growth

Annual Blog Review: 2023

Annual Review 31 min read
Akshay's Blog -> Write Software, Well

Akshay's Blog is now Write Software, Well

4 min read
Books to learn programming with Ruby and Rails

A List of Books to Learn Programming with Ruby and Rails

9 min read
How to fetch a single record from has_many relationship with SQL Subquery

Fix N+1 Queries Without Eager Loading Using SQL Subqueries

In this post, we'll learn how to use a SQL subquery in a Rails app to eliminate N+1 queries and improve performance. We'll profile a real-world example, showing how to fetch a single record from associated has_many records efficiently without eager loading or excessive memory usage.

14 min read
Select Specific Columns

Reduce Memory Usage by Selecting Specific Columns

As your application grows, so do your database tables. If you keep fetching all columns, those extra fields, especially large text or JSON blobs can quietly eat up a lot of memory. This post shows how to reduce memory usage in your Rails apps by selecting only the columns you need from the database.

5 min read
Rails Debugbar

Profiling Ruby on Rails Applications with Rails Debugbar

This post shows how you can get a better understanding of your Ruby on Rails application performance with the Rails Debugbar, a profiling tool inspired by Laravel Debugbar. It also covers how to spot N+1 queries, reduce object allocations, and optimize SQL queries to improve page load times.

11 min read
Strong Parameters in Rails

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.

Controllers 7 min read
Working with HTTP Response in Rails

Working with HTTP Responses in Rails

In this post, we'll learn how to work with the response object in Rails controllers — from inspecting response bodies and headers to setting status codes and content types. This guide also covers key methods like body, status=, content_type, cookies, and more, with practical examples.

Controllers 4 min read
Working with HTTP Requests in Rails

Working with HTTP Requests in Rails

Every web application needs to process incoming HTTP requests. In this post, we’ll take a closer look at how Rails handles requests, how you can access the request object in the controller, and some of the most useful methods it provides to gather meaningful data from the request.

Controllers 8 min read
Rails Parameters

Understanding Rails Parameters

Rails parameters let you access data sent by the browser, both via the URL and forms. In this article, we'll cover the basics of parameters, including what they are, how they work, and why they're important. We'll also learn how you can pass parameters in different formats such as arrays and hashes.

Controllers 9 min read
A Rails Controller for Books

New Series on Rails Controllers

This is the first post in a new series that explores the Rails controllers in detail. This post covers the basics, providing a brief overview of controllers, why we need a controller, and how to create one. We'll start exploring more advanced stuff about controllers starting from the next post.

Controllers 6 min read
Restrict with Error in Rails

Restrict Destroying Dependent Rails Associations with Error

The dependent: :restrict_with_error option is a simple way to enforce data integrity in Rails apps. By preventing deletions of parent records with existing associations and providing helpful errors, it ensures historical data remains intact while guiding users on how to handle dependencies properly.

4 min read
Backup SQLite from a Containerized Rails App Deployed with Kamal

Backup SQLite from a Containerized Rails App Deployed with Kamal

This post walks through backing up a SQLite database inside a Docker container on a remote server, specifically for a Ruby on Rails application deployed with Kamal. We'll begin with the basic commands, then convert them into a reusable shell script and a Rake task for convenience.

4 min read
Rails Instrumentation API

Working with the Rails Instrumentation API

The Instrumentation API in ActiveSupport serves a dual purpose. You can use it to implement the observer (pub-sub) pattern, as well as benchmark how long it took to execute some action. In this post, we'll learn almost everything you need to know about the Rails Instrumentation API.

Rails Internals 5 min read
Ruby on Rails

How a Ruby Method Becomes a Rails Action: Part One

In this post, we will explore how a simple Ruby method, when added to a controller, becomes an action in Rails, ready to process incoming HTTP requests and send responses. We'll also trace the path of an incoming HTTP request to a Rails controller action.

Rails Internals 7 min read

Page 1 of 17

Load More Something went wrong with loading more posts
  • Sign up
  • Homepage

© Write Software, Well 2025 - Powered by Ghost