How to validate the extension of uploaded file when using single uploader for multiple file type?
I am using the single model namely Asset containing the attribute file. Uploader is mounted on file attribute. Asset model having one more attribute called feature_id. feature_id refers to features like video, audio, etc.
So, how should I validate the file type with multiple extension whitelist depending upon feature_id value?
Using ruby 1.9 and rails 3.2.11
Any help will be greatly appreciated.
I ran into the exact same use case:
In Asset.rb
Validate the format of the filename
Use a regular expression to test the file name:
Here you can play with the regex:
http://rubular.com/r/Z3roRDDXAf
Hope this helps!