Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.
So instead of this:
require 'carrierwave/processing/mini_magick'
class LogoUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process :quality => 80
process :resize_to_limit => [800, 800]
process :convert => 'png'
# ...
end
Do this:
require 'carrierwave/processing/mini_magick'
class LogoUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process :convert => 'png'
version :medium do
process :quality => 80
process :resize_to_limit => [800, 800]
end
# ...
end
I'm debugging the code because it's giving me
undefined method '<=' for nil:NilClass)
, that's on the linenext if value_size.send(validity_check, check_value)
.The options I'm passing:
validates :profile_img, file_size: {maximum: 2.megabytes.to_i}
.The following 2 lines don't make sense for me:
Maybe I'm missing something, but
value
cannot be of typeUploader
andString
at the same time: