Commit f0cd9ea4 by Jon Yurek

Changed interpolations to run longer-named ones first, preventing collisions.

parent 87bd86cc
......@@ -198,13 +198,13 @@ module Paperclip
end
def interpolate pattern, style = default_style #:nodoc:
pattern = pattern.dup
self.class.interpolations.each do |tag, l|
pattern.gsub!(/:\b#{tag}\b/) do |match|
l.call( self, style )
interpolations = self.class.interpolations.sort{|a,b| a.first.to_s <=> b.first.to_s }
interpolations.reverse.inject( pattern.dup ) do |result, interpolation|
tag, blk = interpolation
result.gsub(/:#{tag}/) do |match|
blk.call( self, style )
end
end
pattern
end
def queue_existing_for_delete #:nodoc:
......
......@@ -82,7 +82,7 @@ class AttachmentTest < Test::Unit::TestCase
end
should "make sure that they are interpolated correctly" do
assert_equal "1024.omg/1024-bbq/:idwhat/000/001/024.wtf", @dummy.avatar.path
assert_equal "1024.omg/1024-bbq/1024what/000/001/024.wtf", @dummy.avatar.path
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