{"record":{"id":"907b881db6bd4ffe","repo":"carrierwaveuploader/carrierwave","slug":"errors-messages-min-height-error","errorCode":null,"errorMessage":"errors.messages.min_height_error","messagePattern":"errors\\.messages\\.min_height_error","errorType":"exception","errorClass":"CarrierWave::IntegrityError","httpStatus":null,"severity":"error","filePath":"lib/carrierwave/uploader/dimension.rb","lineNumber":58,"sourceCode":"      def height_range; end\n\n    private\n\n      def check_dimensions!(new_file)\n        # NOTE: Skip the check for resized images\n        return if version_name.present?\n        return unless width_range || height_range\n\n        unless respond_to?(:width) || respond_to?(:height)\n          raise 'You need to include one of CarrierWave::MiniMagick, CarrierWave::RMagick, or CarrierWave::Vips to perform image dimension validation'\n        end\n\n        if width_range&.begin && width < width_range.begin\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.min_width_error\", :min_width => ActiveSupport::NumberHelper.number_to_delimited(width_range.begin))\n        elsif width_range&.end && width > width_range.end\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.max_width_error\", :max_width => ActiveSupport::NumberHelper.number_to_delimited(width_range.end))\n        elsif height_range&.begin && height < height_range.begin\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.min_height_error\", :min_height => ActiveSupport::NumberHelper.number_to_delimited(height_range.begin))\n        elsif height_range&.end && height > height_range.end\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.max_height_error\", :max_height => ActiveSupport::NumberHelper.number_to_delimited(height_range.end))\n        end\n      end\n\n    end # Dimension\n  end # Uploader\nend # CarrierWave\n","sourceCodeStart":40,"sourceCodeEnd":67,"githubUrl":"https://github.com/carrierwaveuploader/carrierwave/blob/b5f0abe10ecf6500309fc83e0e8969cf57ba690e/lib/carrierwave/uploader/dimension.rb#L40-L67","documentation":"Raised as CarrierWave::IntegrityError when check_dimensions! sees an image shorter than the lower bound of height_range (message errors.messages.min_height_error, bound formatted via number_to_delimited). Same mechanics as the width checks: base version only, requires MiniMagick/RMagick/Vips for the height method, runs while the file is cached.","triggerScenarios":"Declaring height_range 600..2000 and uploading a 300px-tall banner or wide-but-short strip image (e.g. 1200x200).","commonSituations":"Banners/covers with hard height minimums rejecting legitimately short artwork; UI copy not telling users the minimum; cropping tools allowing crops below the configured floor.","solutions":["Lower the height_range minimum to match real content (or remove the lower bound: height_range nil..2000)","Show the required minimum dimensions in the upload UI and validate with a client-side check (e.g. HTML/JS reading naturalHeight)","Rescue CarrierWave::IntegrityError and attach a specific 'image must be at least X px tall' validation message"],"exampleFix":"# before\nclass CoverUploader < CarrierWave::Uploader::Base\n  include CarrierWave::MiniMagick\n  height_range 600..2000 # 1200x200 image -> IntegrityError min_height_error\nend\n\n# after\nclass CoverUploader < CarrierWave::Uploader::Base\n  include CarrierWave::MiniMagick\n  height_range 150..2000\nend","handlingStrategy":"validation","validationCode":"require 'fastimage'\n\nMIN_H = 600\n_h, h = nil, FastImage.size(params[:image].path)&.last\nreturn render_error(:too_short) if h && h < MIN_H","typeGuard":"def within_height_range?(path, range)\n  _, h = FastImage.size(path)\n  !h.nil? && (range.begin.nil? || h >= range.begin) && (range.end.nil? || h <= range.end)\nend","tryCatchPattern":"begin\n  record.save!\nrescue CarrierWave::IntegrityError => e\n  record.errors.add(:image, :dimensions_invalid, message: e.message)\n  render :new\nend","preventionTips":["Show required minimum dimensions in the upload UI and enforce them client-side (naturalHeight)","Rescue CarrierWave::IntegrityError so short images get a specific validation message","If short banners are legitimate, drop the lower bound: height_range nil..2000"],"tags":["carrierwave","image-dimensions","validation","upload","height"],"backgroundTag":"image-dimension-rejected","analyzedSha":"b5f0abe10ecf6500309fc83e0e8969cf57ba690e","analyzedAt":"2026-08-21T18:07:27.715Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}