episode-178/todo/vendor/plugins/paperclip/lib/paperclip.rb
# 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[:less_than]
# * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
# * +message+: error message to display, use :min and :max as replacements
# * +if+: A lambda or name of a method on the instance. Validation will only
#   be run is this lambda or method returns true.
# * +unless+: Same as +if+ but validates if lambda or method returns false.
Places ActiveRecord-style validations on the size of the file assigned.
Places ActiveRecord - style validations on the size of the file assigned .
def validates_attachment_size name, options = {}
      min     = options[:greater_than] || (options[:in] && options[:in].first) || 0
      max     = options[:less_than]    || (options[:in] && options[:in].last)  || (1.0/0)
      range   = (min..max)
      message = options[:message] || "file size must be between :min and :max bytes."
      attachment_definitions[name][:validations] << [:size, {:min     => min,
                                                             :max     => max,
                                                             :range   => range,
                                                             :message => message,
                                                             :if      => options[:if],
                                                             :unless  => options[:unless]}]
    end
def validates_attachment_size name , options = { } min = options [ :greater_than ] || ( options [ :in ] && options [ :in ] . first ) || 0 max = options [ :less_than ] || ( options [ :in ] && options [ :in ] . last ) || ( 1.0 / 0 ) range = ( min .. max ) message = options [ :message ] || "file size must be between :min and :max bytes." attachment_definitions [ name ] [ :validations ] << [ :size , { :min => min , :max => max , :range => range , :message => message , :if => options [ :if ] , :unless => options [ :unless ] } ] end
Places ActiveRecord-style validations on the size of the file assigned.
Places ActiveRecord - style validations on the size of the file assigned .
name
options