Are active storage named variants still a thing?

the docs for active storage describe how you can create and use named variants:

class User < ApplicationRecord
  has_one_attached :avatar do |attachable|
    attachable.variant :thumb, resize: "100x100"
  end
end

#Call avatar.variant(:thumb) to get a thumb variant of an avatar:
<%= image_tag user.avatar.variant(:thumb) %>

when I try to do that, I just get an error

NoMethodError - undefined method deep_symbolize_keys’ for :thumb:Symbol:`

My suspicion is that rails 6 has thrown this functionality out. Is that correct?

I think it’s the other way around, it’s a new feature already visible in the edge guides you linked to, but not yet available in your version of Rails.

See https://github.com/rails/rails/pull/39135

thank you.

It’s odd - I’m sure I remember seeing that functionality years ago, but perhaps it was paperclip or some other similar provider…

It’s where the idea comes from:

1 Like

What do you do with old variants? I want the variant storage to work kind of like a cache, especially that my users don’t typically look at old images. If a variant is older than a given age, I want to simply remove it - but I have no way to do so. Or do I?

GarageBand on PC

Everything is in the DB so you could try to filter and delete the appropriate VariantRecords along with the associated Blobs and Attachments?