Predefined representations

Rails 7 recently introduced predefined variants as:

class User < ApplicationRecord
  has_one_attached :avatar do |attachable|
    attachable.variant :thumb, resize_to_limit: [100, 100]
  end
end

This PR introduced the change.

It seems that the PR only covers variants but not previews or representations.

I don’t know if there’s any reason for that or if it would make sense to create a PR to accept a syntax like this:

class User < ApplicationRecord
  has_one_attached :file do |attachable| # can be an image or a pdf
    attachable.representation :thumb, resize_to_limit: [100, 100]
  end
end

PR is already there - Allow to use pre-defined variants for previews by richardboehme · Pull Request #45098 · rails/rails · GitHub

1 Like

Oh, I didn’t see it. It’s a pity that it’s not receiving any attention…