Go back Active Storage

active storage variants



resize_to_limit


 resize_to_limit: [300, 300]
  • shrinks larger dimension to match dimensions
  • no effect on smaller images

resize_to_fit 

  • shrinks larger dimension to match dimensions
  • will scale up small images





reusable  variants 


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

<%= image_tag user.avatar.variant(:thumb) %>