Skip to content

Instantly share code, notes, and snippets.

View jagthedrummer's full-sized avatar

Jeremy Green jagthedrummer

View GitHub Profile
@kaspth
kaspth / stowaway.rb
Last active January 19, 2024 19:40
A Rails modeling implementation of https://brandur.org/soft-deletion
create_table :stowaway_records do |t|
t.string :record_type, null: false
t.jsonb :record_attributes, null: false, default: {}
t.timestamps
t.index :record_type
end
class Stowaway::Record < ActiveRecord::Base
def self.preserve(record)
create! record_type: record.class, record_attributes: record.attributes