Permalink
Browse files

Fix 293, 601: STI subclassing overwrites options

Problem: When using STI, and when 'config.cache_classes = true', then
the STI subclass that gets loaded last will overwrite the options for
the others. This is due to using Rails class_attribute with a mutable
hash.

Solution: dup the hash.
  • Loading branch information...
1 parent 9edeb01 commit 2c6b7cb06a016ef147511a10303d207181022e32 @ramn committed Sep 25, 2011
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/paperclip.rb
View
@@ -314,6 +314,8 @@ def has_attached_file name, options = {}
else
write_inheritable_attribute(:attachment_definitions, {})
end
+ else
+ self.attachment_definitions = self.attachment_definitions.dup
end
attachment_definitions[name] = {:validations => []}.merge(options)

0 comments on commit 2c6b7cb

Please sign in to comment.