Files

Paperclip::Validate::ClassMethods

Public Instance Methods

validates_attachment_content_type(*fields) click to toggle source

Places ActiveRecord-style validations on the content type of the file assigned. The possible options are:

  • content_type: Allowed content types. Can be a single content type or an array. Allows all by default.

  • message: The message to display when the uploaded file has an invalid content type.

# File lib/dm-paperclip/validations.rb, line 30
def validates_attachment_content_type(*fields)
  validators.add(Paperclip::Validate::ContentTypeValidator, *fields)
end
validates_attachment_geometry(*fields) click to toggle source

Places ActiveRecord-style validations on the geometry of the file assigned. The required options are:

  • height: a Range of pixels (i.e. 100..300+),

  • width: a Range of pixels (i.e. 100..300+)

# File lib/dm-paperclip/validations.rb, line 38
def validates_attachment_geometry(*fields)
  validators.add(Paperclip::Validate::GeometryValidator, *fields)
end
validates_attachment_presence(*fields) click to toggle source

Places ActiveRecord-style validations on the presence of a file.

# File lib/dm-paperclip/validations.rb, line 22
def validates_attachment_presence(*fields)
  validators.add(Paperclip::Validate::RequiredFieldValidator, *fields)
end
validates_attachment_size(*fields) click to toggle source

Places ActiveRecord-style validations on the size of the file assigned. The possible options are:

  • in: a Range of bytes (i.e. 1..1.megabyte),

  • less_than: equivalent to :in => 0..options

  • greater_than: equivalent to :in => options..Infinity

  • message: error message to display, use :min and :max as replacements

# File lib/dm-paperclip/validations.rb, line 12
def validates_attachment_size(*fields)
  validators.add(Paperclip::Validate::SizeValidator, *fields)
end
validates_attachment_thumbnails(name, options = {}) click to toggle source

Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.

# File lib/dm-paperclip/validations.rb, line 17
def validates_attachment_thumbnails name, options = {}
  self.attachment_definitions[name][:whiny_thumbnails] = true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.