I’m developing a RoR application that uploads a CSV file, then
validates the entries and allows the user to correct columns from the
CSV file. When everything is valid, the user may post the uploaded
data to the database.
I’m successfully uploading the CSV into an “uploads” table with the
record holding the CSV file content, like uploading a JPG file. I’ve
created a class that matches the desired results from a CSV line. I
can parse the CSV file in t an array of the class and validate it into
a “/index” display on the browser. At this point I haven’t put the
data from the CSV into MySQL. I’ve got it in an array like you get
from “model”.find(:all). I put a link on the uploads panel to take me
to the lines panel to show the parsed CSV fields with validation
messages attached as TITLEs on the table cells.
I’m doing a RESTful implmentation, but running into problems with the
resource paths in link_to.
I’m trying to delay putting the parsed CSV results into MySQL until
it’s correct. I’ve been holding it in the array, but now I’m having
trouble making the array available to the edit method after making the
array in the index method.
1st question: I’ve been trying to avoid putting info into a MySQL
table until it was validated, but all the scaffolded code and the
resource links want to see the data in the DB. What approach to
handling the validation and then posting of the data do you recommend?
I’m prepared to re-work my efforts into another approach.
2nd: How may I share the array between the methods? How do I get the
link_to to refer to selected line in an /index panel when “edit”,
“show”, … are selected?