jnicklas/carrierwave — Issue #595: Conditional processing never runs
Author: Stefano1990
Created: 2012-01-27 06:14:03+00:00
State: open

Hi guys

I am encountering this really weird issue.. My code:

class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file

def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

version :avatar, :if => :is_avatar? do
process :resize_to_fill => [65, 65]
end

version :full do
process :resize_to_fit => [652, 800]
end

def extension_white_list
%w(jpg jpeg gif png)
end

def filename
"#{model.user.id}-#{Time.now.to_i}" if original_filename
end

protected
def is_avatar?(image)
return model.is_avatar
end
end

My model has an attribute called "is_avatar". It is boolean. I checked its status by setting the filename to #{model.user.id}-#{model.is_avatar}" and every time the file name turned up to be "1-true" when the other versions are saved. So I can be sure that is_avatar is actually TRUE.

Yet, version :avatar is never run.

I am completely gobsmacked.