Skip to content

Commit

Permalink
added option to not partition directories
Browse files Browse the repository at this point in the history
  • Loading branch information
eadz committed Jun 9, 2008
1 parent dfc4ada commit e1c9c83
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/technoweenie/attachment_fu/backends/file_system_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ def attachment_path_id
((respond_to?(:parent_id) && parent_id) || id).to_i
end

# overrwrite this to do your own app-specific partitioning.
# you can thank Jamis Buck for this: http://www.37signals.com/svn/archives2/id_partitioning.php
# by default paritions files into directories e.g. 0000/0001/image.jpg
# to turn this off set :partition => false
def partitioned_path(*args)
("%08d" % attachment_path_id).scan(/..../) + args
if respond_to?(:attachment_options) && attachment_options[:partition] == false
args
else
("%08d" % attachment_path_id).scan(/..../) + args
end
end

# Gets the public path to the file
Expand Down Expand Up @@ -94,4 +98,4 @@ def current_data
end
end
end
end
end

0 comments on commit e1c9c83

Please sign in to comment.