Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Do not show warning if :class exists in the interpolation URL
Browse files Browse the repository at this point in the history
This fixes #660
  • Loading branch information
sikachu committed Dec 12, 2011
1 parent 3e20907 commit b4ff2c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/paperclip.rb
Expand Up @@ -193,7 +193,7 @@ def class_for(class_name)
def check_for_url_clash(name,url,klass)
@names_url ||= {}
default_url = url || Attachment.default_options[:url]
if @names_url[name] && @names_url[name][:url] == default_url && @names_url[name][:class] != klass
if @names_url[name] && @names_url[name][:url] == default_url && @names_url[name][:class] != klass && @names_url[name][:url] !~ /:class/
log("Duplicate URL for #{name} with #{default_url}. This will clash with attachment defined in #{@names_url[name][:class]} class")
end
@names_url[name] = {:url => default_url, :class => klass}
Expand Down
10 changes: 10 additions & 0 deletions test/paperclip_test.rb
Expand Up @@ -86,6 +86,16 @@ class Dummy2 < ActiveRecord::Base
has_attached_file :blah
end
end

should "not generate warning if attachment is redifined with the same url string but has :class in it" do
Paperclip.expects(:log).never
Dummy.class_eval do
has_attached_file :blah, :url => "/system/:class/:attachment/:id/:style/:filename"
end
Dummy2.class_eval do
has_attached_file :blah, :url => "/system/:class/:attachment/:id/:style/:filename"
end
end
end

context "An ActiveRecord model with an 'avatar' attachment" do
Expand Down

0 comments on commit b4ff2c5

Please sign in to comment.