Guest User

Untitled

a guest
May 16th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment