Commit fafa7c6f by jyurek

Added partition_id as an interpolation

git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@402 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
parent e35fa9eb
...@@ -117,18 +117,21 @@ module Paperclip ...@@ -117,18 +117,21 @@ module Paperclip
# necessary. # necessary.
def self.interpolations def self.interpolations
@interpolations ||= { @interpolations ||= {
:rails_root => lambda{|attachment,style| RAILS_ROOT }, :rails_root => lambda{|attachment,style| RAILS_ROOT },
:class => lambda{|attachment,style| attachment.instance.class.to_s.pluralize }, :class => lambda{|attachment,style| attachment.instance.class.to_s.pluralize },
:basename => lambda do |attachment,style| :basename => lambda do |attachment,style|
attachment.original_filename.gsub(/\.(.*?)$/, "") attachment.original_filename.gsub(/\.(.*?)$/, "")
end, end,
:extension => lambda do |attachment,style| :extension => lambda do |attachment,style|
((style = attachment.styles[style]) && style.last) || ((style = attachment.styles[style]) && style.last) ||
File.extname(attachment.original_filename).gsub(/^\.+/, "") File.extname(attachment.original_filename).gsub(/^\.+/, "")
end, end,
:id => lambda{|attachment,style| attachment.instance.id }, :id => lambda{|attachment,style| attachment.instance.id },
:attachment => lambda{|attachment,style| attachment.name.to_s.pluralize }, :partition_id => lambda do |attachment, style|
:style => lambda{|attachment,style| style || attachment.default_style }, ("%09d" % attachment.instance.id).scan(/\d{3}/).join("/")))
end
:attachment => lambda{|attachment,style| attachment.name.to_s.pluralize },
:style => lambda{|attachment,style| style || attachment.default_style },
} }
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment