RSpec: How to write isolated specs with cookies
Rails offers several methods to manage three types of different cookies along with a session storage for cookies. These...
How to transition the height of elements with unknown/auto height
If you want to collapse/expand elements with dynamic content (and thus unknown height), you can not transition between height: 0...
Use -webkit-line-clamp to natively truncate long (multi-line) texts with an ellipsis
Note: You won't need this for single lines of text. In this case it is better to just use...
How to find child nodes that match a selector with JavaScript
Using querySelector or querySelectorAll in JavaScript, you can easily find descendants of a node that match a given selector.
Checklist for Implementing Design
We have a long-standing checklist for merge requests. However, it hardly matches the intricate requirements for design. This checklist...
Code splitting in esbuild: Caveats and setup
TL;DR Still has caveats. Code splitting is a feature of JavaScript bundlers that can keep huge libraries out of...
Better HTML forms: use type, inputmode, enterkeyhint and autocomplete
Web forms can be made much more usable with a few HTML attributes. Short summary: type: Tells browsers about the...
Preventing users from uploading malicious content
When you allow file uploads in your app, a user might upload content that hurts other users. Our primary concern...
We have deprecated Rack::SteadyETag
Rack::SteadyETag was a Rack middleware that generates the same default ETag for responses that only differ in XOR-masked...
Rails: Fixing ETags that never match
Every Rails response has a default ETag header. In theory this would enable caching for multiple requests to the same...
Breaking changes for boolean attributes in HAML 6
Haml 6 has some breaking changes regarding boolean attributes. Only the following attributes and aria/data attributes are considered boolean attributes...
Simple Form: Rendering errors without an appropriate attribute
Usually you add errors to :base in ActiveRecord, in case no appropriate attribute could be used to add the error...
Rails: Assigning associations via HTML forms
Let's say we have posts with an attribute title that is mandatory. Our example feature request is to tag...
Rails: Composing an ETag from multiple records
Rails offers the fresh_when method to automatically compute an ETag from the given record, array of records or scope...
Rails: Your index actions probably want strict_loading
By activating strict_loading you force developers to address n+1 queries by preloading all associations used in the index...
How to enable template coverage support for simplecov
Since Ruby 3.2.0 you can measure coverage support for eval statements and support has been added for the simplecov gem...
Rails Partials
Rails partials have a lot of "hidden" features and this card describes some non-obvious usages of Rails Partials.
How to turn images into inline attachments in emails
Not all email clients support external images in all situations, e.g. an image within a link. In some cases, a...
Rails: Encrypting your database information using Active Record Encryption
Since Rails 7 you are able to encrypt database information with Active Record. Using Active Record Encryption will store an...
Rails: Accessing helper methods from a controller
In Rails 5+ you can access a helper from a controller using the helpers method: # Inside a controller action
Dynamic super-overridable methods in Ruby – The Pug Automatic
How a macro can dynamically define a method that can be overridden with super in the same class.
Jasmine: Mocking ESM imports
In a Jasmine spec you want to spy on a function that is imported by the code under test. This...
Jasmine: Creating DOM elements efficiently
Jasmine specs for the frontend often need some DOM elements to work with. Because creating them is such a common...
Jasmine: Cleaning up the DOM after each test
Jasmine specs that work with DOM elements often leave elements in the DOM after they're done. This will leak...