justin․searls․co

Am I right to use Rails 7’s normalizes…

Am I right to use Rails 7’s normalizes feature as a way to set an app-layer default value for a model attribute?

class Basket < ApplicationRecord
  normalizes :fruits_array, with: ->(fruits) { fruits || [] }
end

Got a taste for fresh, hot takes?

Then you're in luck, because you can subscribe to this site via RSS or Mastodon! And if that ain't enough, then sign up for my newsletter and I'll send you a usually-pretty-good essay once a month. I also have a solo podcast, because of course I do.