Guest User

Untitled

a guest
Feb 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. protected
  2. def validate
  3. errors.add("Uploaded file", "is not a valid image file.") unless uploaded_file_has_valid_extension? if new_record?
  4. end
  5.  
  6. def uploaded_file_has_valid_extension?
  7. %w(.jpg .png).include?(File.extname(self.file.path)) if self.file
  8. end
Add Comment
Please, Sign In to add comment