daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest May 16th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. has_attachment :storage => :file_system,
  2.                  :max_size => 10.megabytes,
  3.                  :thumbnails => { :thumb => '200x200' }
  4.  
  5.  def validate
  6.    errors.add_to_base("You must choose a file to upload.") unless self.filename
  7.  
  8.    unless self.filename == nil
  9.      # Images should be less than 10MB
  10.      [:size].each do |attr_name|
  11.        enum = attachment_options[attr_name]
  12.        unless enum.nil? || enum.include?(send(attr_name))
  13.          errors.add_to_base("Files must be smaller than 10MB in size.")
  14.        end
  15.      end
  16.  
  17.    end
  18.  end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top