Carl Wright
2007-Apr-13 16:46 UTC
Processing a CSV file to validity before putting it in the table
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? Thanks, Carl --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Federico Fernandez
2007-Dec-12 21:57 UTC
Re: Processing a CSV file to validity before putting it in t
I am trying to do exactly the same thing... did you get an answer in some other forum? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---