Understanding database Indexes in PostgreSQL
I found the linked article very helpful to refresh my understanding of database indexes. As a small bonus, it includes...
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...
Beware when using ActiveSupport time and date calculation methods
Rails Active Support provides some helpful methods for calculating times and dates, like Duration#ago or Duration#from...
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...
Rails migration: Changing a column type without losing the content
The change_column method for rails migrations support casting with a custom SQL statement. This allows us to change a...
Story Checklist Template
This is an story checklist I use to work on stories. For this purpose I extracted several cards related to...
Rails Partials
Rails partials have a lot of "hidden" features and this card describes some non-obvious usages of Rails Partials.
Rails: Using database default values for boolean attributes
In the past we validate and set default values for boolean attributes in Rails and not the database itself.
Carrierwave: Custom file validations inside custom Uploaders
Carrierwave's BaseUploader can have some validations that you can use by overriding a certain method, which's expected name...
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...
Postgres: DISTINCT ON lets you select only one record per ordered attribute(s) for each group
To retrieve only unique combinations of the selected attributes: You can omit rows, where all selected columns are equal with...
Signed URLs with Ruby on Rails
Using ActiveRecord's #signed_id and .find_signed methods you can create URLs that expire after some time. No conditionals...
Why Sidekiq Jobs should never be enqueued in an `after_create` or `after_save` callback
When an object is created / updated, various callbacks are executed in this order: before_validation after_validation before_save
Ruby object equality
TLDR if you define a equality method for a class you must also implement def hash. Ruby has a lot...
Bookmarklet: cards Markup Link Bookmarklet
The cards editor has a feature "Cite other card" to create links to other cards in the same deck as...
Rails: Use STI in Migration
tl;dr You should decouple migrations from models by embedding models into the migration. To use STI in this scenario...
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...
Variable fonts: Is the performance trade-off worth it? - LogRocket Blog
Variable fonts are popular for two reasons: they expand design possibilities and improve website performance. While the former statement is...
Chrome DevTools: Treasure (Overview)
tl;dr The Chrome DevTools are a neat collection of tools for the daily work as a web developer. If...
ActiveType::Object: Be careful when overriding the initialize method
ActiveType::Object inherits from ActiveRecod::Base and is designed to behave like an ActiveRecord Object, just without the database...
Debug flaky tests with an Unpoly observeDelay
Unpoly's [up-observe], [up-autosubmit] and [up-validate] as well as their programmatic variants up.observe() and up.autosubmit...
Rails: Validations of Dates, Numerics and Strings with ComparisonValidator
tl;dr Since Rails 7+ you can use ComparisonValidator for validations like greater_than, less_than, etc. on dates, numerics...