Validate belongs_to association in Rails
Eight years ago, Rails 5 made the belongs_to
association required by default. This solved a lot of problems with orphaned records in the database. But sometimes, you need to have an optional association, which may lead to situations that you don’t expect.