Skip to main content

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

Rails • Asked by Aaron Xavier

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.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.