So Im trying to implement a file upload functionality where when a user uploads a file, I can read that into a File object and process it accordingly:
def create
name = params[:upload]['datafile'].original_filename
directory = "public/data"
# create the file path
path = File.join(directory, name)
# read the file
File.open(params[:upload][:datafile], 'rb') { | file |
# do something to the file
}
end
It throws an error with "can't convert Tempfile into String" on the File.open when I try to read the file.
What am I missing ?