Report abuse


			
--- a/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb
+++ b/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb
@@ -103,8 +103,10 @@ module Technoweenie # :nodoc:
       delegate :content_types, :to => Technoweenie::AttachmentFu

       # Performs common validations for attachment models.
+      # If you define a +perform_attachment_validation?+ method 
+      # it will determine if validation is run or not.
       def validates_as_attachment
-        validates_presence_of :size, :content_type, :filename
+        validates_presence_of :size, :content_type, :filename, :if => :perform_attachment_validation?
         validate              :attachment_attributes_valid?
       end

@@ -339,8 +341,14 @@ module Technoweenie # :nodoc:
           self.size = File.size(temp_path) if save_attachment?
         end

+        # Override this method in your model to determine if validations are run or not.
+        def perform_attachment_validation?
+          true
+        end
+
         # validates the size and content_type attributes according to the current model's options
         def attachment_attributes_valid?
+          return unless perform_attachment_validation?
           [:size, :content_type].each do |attr_name|
             enum = attachment_options[attr_name]
             errors.add attr_name, ActiveRecord::Errors.default_error_messages[:inclusion] unless enum.nil? || enum.include?(send(attr_name))