CSV Upload, Parse and for each record created - show the status
I am working on a project and running into issues on how to accomplish this.
- I am using Wicked Form steps for better UX. Steps are: a. Upload CSV, b. Confirm Data, c. Finalize/Add to database
- Upload CSV is fine, then while looping though the rows of CSV, add the records to an object for later use. CSV.foreach(file.path, headers: true, header_converters: :symbol) do | row | @new_ledger_data << row.to_h end
- Step: Confirm Data - Show the table @new_ledger_data ---------- up to this I am done. Step 4 is where the issue is.
- Step: Finalize - This is where I would like the @new_ledger_data.each to loop thought and for each row, Create a new record AND** immediately update the view with newly added record to give the user feedback using AJAX, before moving to the next row of the loop.**
I have used the remote: true on my form (when the user hits Finalize) and it submits it goes though the loop and creates the records BUT does not stop in between to update the view. In another words it completes the whole process, then shows the completed table, rather giving feedback to the user with single record at a time.