Uploading a file in PHP results in a map. One of the keys, tmp_name, allows the user to manipulate the file without having to move it around. I’d like to do the same for Ruby on Rails.
I have a form that takes a .csv file. With this, I’m trying to populate a database. However using just the file field from the form, I get a type of ActionController::UploadedFile which doesn’t allow me to do CSV.open or iterate over it. So how can I access the file uploaded without moving it into my project and then iterate over it? Thanks.
The method
ActionController::UploadedFile#pathshould return the path of the tmp file on the server. You also have a handy#readmethod that returns the content of the file.