0

I am using rails to make a feature designed for uploading CSV's and then taking the CSV's and making rails objects w/ them (i.e. 1 csv row equates to an object in the database). Right now, this is a 2 step process.

I am using the wicked gem for this, and have success bouncing between pages for the forms. The structure seems to be functioning fine.

The problem is in all of the examples i have seen the authors are making a single model that is backed by a database record, and can use things like id's and the object's state to track progress in the form.

From my understanding, this is a standard Wicked controller action with psuedo-code for what I am trying to accomplish

def show
    if step == :step_one
      # get the user_id for whose objects these belong to
      # and get the CSV file
    end

    if step == :step_two
      # EITHER
      # output errors for user to fix
      # output success
    end

    render_wizard
  end

I guess my main question is, how can i track state and use forms (i do not have access to form_for because it's not an object) in this process? And if Wicked isn't designed for this, how can I implement this in a multi-step form?

Any help for how to tackle this is immensely appreciated!

James N
  • 523
  • 1
  • 8
  • 30
  • The two step process is 1: upload the CSV, 2: Write the CSV to the database? – katniss.everbean Aug 10 '17 at 23:04
  • @katniss.everbean yes. step 1 grabs the file and user_id, which is passed to a service to handle the heavy lifting. Step 2 either displays any error found from the service call, or outputs a success message. – James N Aug 10 '17 at 23:09
  • Are you storing the CSV itself anywhere? – katniss.everbean Aug 10 '17 at 23:12
  • @katniss.everbean no. CSV is looped through, all data is taken out and all the data that was found with no errors is stored in the DB. CSV is never saved, stored, and i never write to it. – James N Aug 10 '17 at 23:14

0 Answers0