Skip to content

Instantly share code, notes, and snippets.

irb(main):002:0> p = Page.new
irb(main):005:0> p.image = File.open("/Users/jtj/sample_assets/a.JPG")
irb(main):008:0> p.save
# Delay while versions are uploaded
irb(main):009:0> p.image.url
=> https://s3.amazonaws.com/dk.workingbits.dts/uploads/page/image/17/a.JPG
irb(main):011:0> p.image.url(:thumbnail)
=> "https://s3.amazonaws.com/dk.workingbits.dts/uploads/page/image/17/thumbnail_a.JPG"
@chrisbloom7
chrisbloom7 / README.md
Created June 6, 2011 07:16
A cheap knock off of the default validates_length_of validator, but checks the filesize of a Carrierwave attachment

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'