Ask A Question

Notifications

You’re not receiving notifications from this thread.

CSV Upload, Parse and for each record created - show the status

Aaron Xavier asked in Rails

I am working on a project and running into issues on how to accomplish this.

  1. I am using Wicked Form steps for better UX. Steps are: a. Upload CSV, b. Confirm Data, c. Finalize/Add to database
  2. 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
  3. Step: Confirm Data - Show the table @new_ledger_data ---------- up to this I am done. Step 4 is where the issue is.
  4. 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.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.