Skip to content

Instantly share code, notes, and snippets.

@julesfern
Created October 29, 2008 19:20
Show Gist options
  • Save julesfern/20788 to your computer and use it in GitHub Desktop.
Save julesfern/20788 to your computer and use it in GitHub Desktop.
protected
def validate
errors.add("Uploaded file", "is not a valid image file.") unless uploaded_file_has_valid_extension? if new_record?
end
def uploaded_file_has_valid_extension?
%w(.jpg .png).include?(File.extname(self.file.path)) if self.file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment