mount_uploader :photo, PhotoUploader
validate :check_landscape
def check_landscape
if photo.width<photo.height
errors.add :photo, "is not a landscape."
puts "Error ! not a Landscape Image"
else if photo.width>photo.height
puts " Landscape Image"
end
end
end
, если вы ищете active_storage has_many_attached
has_many_attached :images
validate: active_storage_many_images
def active_storage_many_images
images.each do |image|
image.blob.analyze unless image.blob.analyzed?
width = image.blob.metadata[:width]
height = image.blob.metadata[:height]
if width<height
errors.add :image, "Additional images are not landscape"
puts "ACTIVE STORAGE IMAGE ERROR !!"
end
end
end