module Polypaperclip::InstanceMethods
Public Instance Methods
each_attachment() { |name, paperclip_attachment_for(name)| ... }
click to toggle source
we override Paperclip’s each_attachment
so that we proxy through the attachments model
# File lib/polypaperclip.rb, line 73 def each_attachment self.class.polypaperclip_definitions.each do |name, definition| yield(name, paperclip_attachment_for(name)) end end
paperclip_attachment_for(name)
click to toggle source
# File lib/polypaperclip.rb, line 90 def paperclip_attachment_for(name) @_paperclip_attachments ||= {} @_paperclip_attachments[name] ||= Polypaperclip::Attachment.new(name, self, self.class.polypaperclip_definitions[name]) end
save_attached_files()
click to toggle source
# File lib/polypaperclip.rb, line 79 def save_attached_files #premptively save each attachment Paperclip.log("Saving attachments.") each_attachment do |name, attachment| if attachment && attachment.instance attachment.instance.save attachment.send(:save) end end end