Short notes from engineering

Micro-posts on programming and patterns as we build Tramline in public. Follow this feed if you find these bits interesting.


2023 / Jan 18 — 13:41
kitallis

All these years of using Rails, I had no idea has_one did this.

More importantly with a relationship like follows,

class Model < ActiveRecord
  has_one :build
end

class Build < ActiveRecord
  has_one_attached_file :file
end

If I create_build on Model if one already exists, it will:

  1. Delete that Build, create a new one and attach it to Model
  2. Kickoff an ActiveStorage::PurgeJob and delete the file from GCS/AWS

This is highly uncomfortable.