You should probably load your JavaScript with <script defer>

Posted Over 2 years ago by Henning Koch.

It is generally discouraged to load your JavaScript by a tag in the : The reason is that a tag will pause the DOM parser until the script has loaded and executed. This will delay the browser's first contentful paint. A much better default is to load your scripts with a tag: A deferred script has many...

Using multiple MySQL versions on the same linux machine using docker

Posted Over 2 years ago by Daniel Straßner.

We had a card that described how to install multiple mysql versions using mysql-sandbox. Nowadays with the wide adoption...

NVM: How to automatically switch version when changing directories

Posted Almost 3 years ago by Arne Hartherz.

The Node Version Manager allows installing multiple NodeJS versions and switching between them. By default, it does not automatically switch...

Accessing JavaScript objects from Capybara/Selenium

Posted Almost 3 years ago by Dominic Beger.

When testing JavaScript functionality in Selenium (E2E), you may need to access a class or function inside of a evaluate...

Marko Denic's list of TIL for HTML

Posted Almost 3 years ago by Emanuel.
markodenic.com

Table of content for the linked article: 1. The `loading=lazy` attribute 2. Email, call, and SMS links

Heads up: Byebug has problems with zeitwerk

Posted Almost 3 years ago.

I encountered a unlucky behavior of byebug 11.1.3 (the most recent version at time of writing) when using it with...

RSpec: Ensuring a method is called on an object that will be created in the future

Posted Almost 3 years ago.
rspec.info

rspec >= 3.1 brings a method and_wrap_original. It seems a bit complicated at first, but there are use cases...

How to use ActiveSupport Concerns with dynamic relations

Posted Almost 3 years ago.

The usual way to build a relation in a ActiveSupport::Concern is this: module MyModule extend ActiveSupport::Concern

Carrierwave: Using a nested directory structure for file system performance

Posted Almost 3 years ago by Arne Hartherz.

When storing files for lots of records in the server's file system, Carrierwave's default store_dir approach may...

Carrierwave: How to remove container directories when deleting a record

Posted Almost 3 years ago by Arne Hartherz.

When deleting a record in your Rails app, Carrierwave automatically takes care of removing all associated files. However, the file...

Delivering Carrierwave attachments to authorized users only

Posted About 3 years ago by Dominic Beger.

To attach files to your records, you will need a new database column representing the filename of the file...

Capybara: Preventing server errors from failing your test

Posted About 3 years ago by Henning Koch.

When your Rails application server raises error, Capybara will fail your test when it clears the session after the last...

CarrierWave: Default Configuration and Suggested Changes

Posted About 3 years ago by Dominik Schöler.

CarrierWave comes with a set of default configuration options which make sense in most cases. However, you should review these...

Regular Expressions: Quantifier modes

Posted About 3 years ago by Henning Koch.

When you repeat a subpattern with a *, + or {...} operator, you may choose between greedy, lazy and possessive modes. Switching modes...

ActiveType #change_association: Define { autosave: true } on parent models

Posted About 3 years ago by Jakob Scholz.

Consider the following models and form models: class Parent < ApplicationRecord has_many :children, class_name: 'Child', foreign_key: 'parent_id...

Rails: Postgres Partial Indexing

Posted About 3 years ago by Henning Koch.
johnnunemaker.com

PostgreSQL has partial indexes. With a partial index you tell Postgres to only index rows matching a given query.

DNS debug tools

Posted About 3 years ago.

There are several tools for DNS debugging which offer you more or less information. Most of the time the more...

Fixing memory leaks in the browser

Posted Over 3 years ago.
nolanlawson.com

In my experience, the most common sources of memory leaks are APIs like these: addEventListener. This is the most common...

Using the Truemail gem to validate e-mail addresses

Posted Over 3 years ago by Arne Hartherz.

The Truemail gem (not to be confused with truemail.io) allows validating email addresses, e.g. when users enter them into a...

Transporting blank values in URL queries

Posted Over 3 years ago by Henning Koch.

URLs can transport key/value pairs ("parameters") using this syntax: /path?foo=bar If the value is blank, mind these subtle...

Configuring Webpacker deployments with Capistrano

Posted Over 3 years ago by Dominik Schöler.

When deploying a Rails application that is using Webpacker and Capistrano, there are a few configuration tweaks that optimize the...

Minidusen: Filtering associated records

Posted Over 3 years ago by Henning Koch.
github.com

Minidusen lets you find text in associated records. Assume the following model where a Contact record may be associated with...

Passive event listeners may speed up your scroll and touch events

Posted Over 3 years ago by Michael Leimstädtner.
github.com

Scroll and touch event listeners tend to be computationally expensive as they are triggered very often. Every time the event...

How to negate scope conditions in Rails

Posted Over 3 years ago by Arne Hartherz.

Sometimes you want to find the inverse of an ActiveRecord scope. Depending on what you want to achieve, this is...