public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
added option to not partition directories
eadz (author)
Mon Jun 09 03:02:13 -0700 2008
commit  e1c9c83ed7d338651b51c23b0d583ff6c9c5fe0e
tree    6ff533a89eb07e3ae9862ede4d65d9d25eb30997
parent  dfc4ada55dd0f982a6fc2fbaa297e58070096105
...
31
32
33
34
35
 
 
36
37
 
 
 
 
 
38
39
40
...
94
95
96
97
98
 
...
31
32
33
 
 
34
35
36
 
37
38
39
40
41
42
43
44
...
98
99
100
 
101
102
0
@@ -31,10 +31,14 @@ module Technoweenie # :nodoc:
0
           ((respond_to?(:parent_id) && parent_id) || id).to_i
0
         end
0
       
0
- # overrwrite this to do your own app-specific partitioning.
0
- # you can thank Jamis Buck for this: http://www.37signals.com/svn/archives2/id_partitioning.php
0
+ # by default paritions files into directories e.g. 0000/0001/image.jpg
0
+ # to turn this off set :partition => false
0
         def partitioned_path(*args)
0
- ("%08d" % attachment_path_id).scan(/..../) + args
0
+ if respond_to?(:attachment_options) && attachment_options[:partition] == false
0
+ args
0
+ else
0
+ ("%08d" % attachment_path_id).scan(/..../) + args
0
+ end
0
         end
0
       
0
         # Gets the public path to the file
0
@@ -94,4 +98,4 @@ module Technoweenie # :nodoc:
0
       end
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments

    No one has commented yet.