Say you wrap your index view in a form to apply different filters like pagination or a search query. On...
When you want to filter records in a model where a string column roughly matches a given term, you can...
In Rails, the implicit_order_column (added in Rails 6) is a configuration option that helps you define the default...
Why Rails has multiple schema formats When you run migrations, Rails will write your current database schema into db/schema.rb. This...
DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It...
ActiveStorage does not provide any built-in way of implementing authentication for the available DirectUpload endpoint in Rails. When using...
Added methods to keep the line number steady while you time-travel between commits: Copy the file to a new...
For long running scripts it is useful to show a indicator for the progress in the terminal. Alternatively you can...
PostgreSQL can cosplay as a full-text search engine. It doesn't have the features or fidelity of ElasticSearch or...
There are several ways to run a single spec. I usually copy the spec file path with the line number...
Given there is a user with an attachable avatar: class User < ApplicationRecord has_one_attached :avatar end
Given there is a user with an attachable avatar: class User < ApplicationRecord has_one_attached :avatar end
The key to unlocking the full potential of LLMs in coding lies in crafting precise prompts. The main challenge is...
When debugging slow SQL queries, it’s helpful to understand the database engine's query plan. Whenever you execute a...
Some key highlights and points from the linked article TestProf II: Factory therapy for your Ruby tests. The Problem with...
A lesser known fact about PG enums is that they are ordered. This can be really handy when values have...
Slow test suites are a major pain point in projects, often due to RSpec and FactoryBot. Although minitest and fixtures...
While the main goal always is to prevent long-running queries in the first place, automatic timeouts can serve as...
You can improve your LIKE / ILIKE search queries in PostgreSQL by adding a GIN index with an operate class ("opclass...
Recently I needed to benchmark an Active Record query for performance measurements. I wrote a small script that runs each...
You are given two CSS selectors that you do not control. How can you build a new selector that matches...
Reacting on a class getting added can be done with a mutation observer. Example: const items = document.querySelectorAll('.item') const expectedClass...
I was recently asked to optimize the response time of a notoriously slow JSON API endpoint that was backed by...