Download the file as a string (Ruby on rails)

<h4>Upload CSV File:</h4> <%= form_tag(import_patients_path, :method =>'post', :multipart => true) %> <%= file_field_tag 'csvfile' %> <br /> <%= submit_tag "Upload CSV Data" %> </form> 

From the controller, I just need to get the file as a string. Is there an easy way to do this? (I do not need to save the file anywhere)

+4
source share
1 answer

You can do something like:

 csv_data = params[:uploaded_file].read 
+5
source

Source: https://habr.com/ru/post/1342330/


All Articles