For Rails models where only one of multiple attributes may be filled out at the same time, there is no...
Ruby has two different ways to match the start and the end of a text: ^ (Start of line) and $ (End...
We are using assignable_values for managing enum values in Rails. Nevertheless Rails is adding more support for enum attributes...
When two classes implement the same behavior (methods, callbacks, etc.), you should extract that behavior into a trait or module...
If the project team consists of at least 2 members, do a daily standup. It should not take much longer...
It is very common to parse dates from strings. It seems obvious to use Date.parse for this job. However this...
In the past we validate and set default values for boolean attributes in Rails and not the database itself.
CarrierWave comes with a set of default configuration options which make sense in most cases. However, you should review these...
Postgres supports multiple built-in range datatypes: int4range int8range numrange tsrange (range with timestamp without timezone) tstzrange (range with timestamp...
There are several ways to run a single spec. I usually copy the spec file path with the line number...
Version 3.7.0 broke some things in complex forms. Sorry for that. Concurrent user input is hard. 3.7.1 This change fixes...
There is a practical short list for valid/invalid example email addresses - Thanks to Florian L.! The definition for valid emails...
tl;dr Do not use the option optional on association declarations with a symbol, lambda or proc. Explanation Association declarations...
Since Rails 7 you are able to encrypt database information with Active Record. Using Active Record Encryption will store an...
If validations failed for a record, and you want to find out if a specific validation failed, you can leverage...
Use form models to handle this problem Or soften the validation to validates_presence_of :parent
validates_acceptance_of :terms only works if terms is set to a value. The validation is skipped silently when terms...
In Ruby you can communicate between processes with sockets. This might be helpful in tests that validate parallel executions or...
This is a personal post-mortem analysis of a project that was mainly build to provide a REST API to...
If you require your Rails models manually, pay attention to the path you use. Unless you have...
The 90s are calling: they want their tables back. Unfortunately, you need them all for laying out your HTML emails...
We have often felt the pain where our models need to serve too many masters. E.g. we are adding a...
Enumerable#all? returns true for an empty collection. This totally makes sense but you have to think about it when...
When you're developing a gem, never list the same dependency as both runtime and development dependency in your .gemspec...