Hi, i have small problem when you upload file by input type=file to
rails then in rails it is represented by one of following StringIO,
File, Tempfile
Is it all? Or can it be represented by also other class?
I need to know this because i have my own validation of file kind and
when is mime type invalid then i want to put msg to record.errors and i
also want to dont upload this file in next step by my upload method so i
call in validation on invalid type somethig like
if file.is_a?(StringIO) then
file.string = ''
file.close
file = nil
record.errors.add attr, 'STRINGIO'
elsif file.is_a?(File) then
File.unlink(file.path)
file = nil
record.errors.add attr, 'FILE'
elsif file.is_a?(Tempfile)
record.errors.add attr, 'TEMPFILE'
File.unlink(file.path)
file = nil
else
record.errors.add attr, 'Some orher class'+file.class.to_s
file = nil
end