From ec40e6ae678861329728bb1decec92b8aaacab73 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 31 Jul 2012 10:39:59 -0400 Subject: [PATCH] new outfit image filename: preview instead of thumb, one more partition level --- app/models/outfit_image_uploader.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/outfit_image_uploader.rb b/app/models/outfit_image_uploader.rb index bcfed59d..6bbf26c4 100644 --- a/app/models/outfit_image_uploader.rb +++ b/app/models/outfit_image_uploader.rb @@ -20,12 +20,20 @@ class OutfitImageUploader < CarrierWave::Uploader::Base end def filename - "thumb.png" + "preview.png" end def store_dir - partition_id = model.id / 1000 - partition_dir = "%03d" % partition_id - "outfits/#{partition_dir}/#{model.id}" + "outfits/#{partition_dir}" + end + + # 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