Commit 7a2e2ed8 by Pavel Forkert Committed by Jon Yurek

Do not save class instances, save their names.

Saving instances causes memory leaks in development mode in rails.
parent 3e6d9333
......@@ -318,7 +318,7 @@ module Paperclip
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 @@ module Paperclip
# }
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
......
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