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

Commit

Permalink
Do not save class instances, save their names.
Browse files Browse the repository at this point in the history
Saving instances causes memory leaks in development mode in rails.
  • Loading branch information
fxposter authored and Jon Yurek committed Sep 30, 2011
1 parent 3e6d933 commit 7a2e2ed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/paperclip.rb
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/paperclip/missing_attachment_styles.rb
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/paperclip_missing_attachment_styles_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 7a2e2ed

Please sign in to comment.