Ruby's standard library includes a class for creating temporary directories. Similar to Tempfile it creates a unique directory name...
tl;dr Since Rails 6+ you can use before? and after? to check if a date/time is before or after...
To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...
A memory leak is an unintentional, uncontrolled, and unending increase in memory usage. No matter how small, eventually, a leak...
For Rails models where only one of multiple attributes may be filled out at the same time, there is no...
When you build a JSON API you need to come up with a style to represent attributes, pagination, errors or...
Greg Molnar has written a neat article about creating a single-file Rails app. This is not meant for production...
Sometimes the need arises for SSL in local development. We have guides for different webservers, this one is for puma...
When your Rails application offers downloading a bunch of files as ZIP archive, you basically have two options:
Recently we detected a memory leak in one of our applications. Hunting it down, we found that the memory leak...
The linked content includes a few design patterns implemented with Ruby on Rails. What is the card indented to achieve...
This should be fixed in the latest LTS-branches of our mysql2 fork, 0.2.x-lts and 0.3.x-lts...
To read the Rails session from a Rack middleware, use env['rack.session']. It's an ActionDispatch::Request::Session object.
Issue: You have an app using jsbundling-rails and esbuild. After deploy, the assets built by esbuild are missing in...
In case you have trouble with the zeitwerk autoloader, you can check out the documentation Autoloading and Reloading Constants and...
tl;dr Since Rails 6.1+ you can use .compact_blank or .compact_blank! to remove blank values from collections (e.g...
When paginating records, we usually need to know the number of total records in order to render pagination links. Popular...
I recently wanted to add a model for address information but also wanted to add a unique index to those...
Imagine these models and associations: class Deck < ApplicationRecord has_many :cards end class Card < ApplicationRecord belongs_to :deck, optional: true...
When changing code in mailers, updating the corresponding mailer preview can be forgotten very easily. Mailer previews can be tested...
When redirecting you should take care to use the right HTTP status code. From controllers When redirecting from a controller...
Recent IRB versions include a multi-line autocomplete which may be helpful to novice users but can be distracting.
It might sometimes be useful to check whether your Rails application accesses the file system unnecessarily, for example if your...
While verifying doubles in RSpec is a good default, it is limited in the amount of methods it actually is...