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