Permalink
Browse files

Do not save class instances, save their names.

Saving instances causes memory leaks in development mode in rails.
  • Loading branch information...
fxposter authored and jyurek committed Sep 29, 2011
1 parent 3e6d933 commit 7a2e2ed8f2cedf407a818ab27f3ef3818a35d672
View
@@ -318,7 +318,7 @@ def has_attached_file name, options = {}
end
attachment_definitions[name] = {:validations => []}.merge(options)
- Paperclip.classes_with_attachments << self unless Paperclip.classes_with_attachments.include?(self)
+ Paperclip.classes_with_attachments << self.name unless Paperclip.classes_with_attachments.include?(self.name)
Paperclip.check_for_url_clash(name,attachment_definitions[name][:url],self.name)
after_save :save_attached_files
@@ -38,7 +38,8 @@ def self.save_current_attachments_styles!
# }
def self.current_attachments_styles
Hash.new.tap do |current_styles|
- Paperclip.classes_with_attachments.each do |klass|
+ Paperclip.classes_with_attachments.each do |klass_name|
+ klass = Paperclip.class_for(klass_name)
klass.attachment_definitions.each do |attachment_name, attachment_attributes|
# TODO: is it even possible to take into account Procs?
next if attachment_attributes[:styles].kind_of?(Proc)
@@ -15,7 +15,7 @@ class PaperclipMissingAttachmentStylesTest < Test::Unit::TestCase
assert_kind_of Set, Paperclip.classes_with_attachments
assert Paperclip.classes_with_attachments.empty?, 'list should be empty'
rebuild_model
- assert_equal [Dummy].to_set, Paperclip.classes_with_attachments
+ assert_equal ['Dummy'].to_set, Paperclip.classes_with_attachments
end
should "enable to get and set path to registered styles file" do

0 comments on commit 7a2e2ed

Please sign in to comment.