I have quite specific issue. I have application where I need to import data in CSV file, which is after upload processed and then the overview page with results is shown to user.
I have already methods how to parse a CSV file. It works OK. But its just 1 step form:
-
New – method and erb file with form
-
Method after post which processes the CSV file => and the data are in DB.
It’s working fine, but I want also automatically generate a CSV file with rows which failed on first upload. I have written method for that, according to this link. But unfortunately the user experience from this approach is terrible. Because, if you generate new CSV file with errors, it just sends a download popup invoked by method:
send_data errCSV, :type => 'text/csv; charset=iso-8859-1; header=present', :disposition => "attachment; filename=#{errFile}.csv"
After the 2nd POST method I want to add a redirect to another view, of which will contain something like “Import overview” header and number of errors, number of correct lines and also a link on method to invoke this temporary downloadable file.
Then my problem is, how can I effectively and without saving a CSV go through 3 step wizard?
EDIT
def upload_csv
#method which render form
end
def import_csv
#method implemented logic for parsing CSV
#POST METHOD
redirect_to overview_method_view
end
def overview
#method which could create a overview
end
And I need pass values(suppose an array) between import_csv and overview. I don’t want to save any file. Just considering using Session.
could you specify which is your 2nd POST method? I think that I don’t fully understand the problem.
By the way, if you want to mantain info between request but you don’t want to use the csv generated, you’ll have to use the DB, session or flash
Edit:
You could use session in this case, you’ll only have to do:
Hope it helps!