Yes, I know that the paperclip has validates_attachment_content_type, but I really want it validate_by_file_extension ... that means ... I have an array of file extensions allowed in my app, and I want to see if there is a file extension in that array about uploading files, and if I do not want to start uploading it and kick back Do not have an error.
How do I do this?
You can define your own verification methods:
Valid: validate_by_file_extension def validate_by_file_extension errors.add_to_base ("invalid file extension") unless ALLOWED_EXTENSIONS.include? (File.extname (attachment_file_name)) End But you can not easily get back to the rail before uploading, as in most cases your rail control mechanism is called , The file has been streamed and a temporary file has been created. You have to go further on the stack to stop things from being started for uploading.
Comments
Post a Comment