new outfit image filename: preview instead of thumb, one more partition level

This commit is contained in:
Emi Matchu 2012-07-31 10:39:59 -04:00
parent c630cde66c
commit ec40e6ae67

View file

@ -20,12 +20,20 @@ class OutfitImageUploader < CarrierWave::Uploader::Base
end end
def filename def filename
"thumb.png" "preview.png"
end end
def store_dir def store_dir
partition_id = model.id / 1000 "outfits/#{partition_dir}"
partition_dir = "%03d" % partition_id end
"outfits/#{partition_dir}/#{model.id}"
# 123006789 => "123/006/789"
def partition_dir
partitions.map { |partition| "%03d" % partition }.join('/')
end
# 123006789 => [123, 6, 789]
def partitions
[6, 3, 0].map { |n| model.id / 10**n % 1000 }
end end
end end