You're right, Matt. I should just accept the file and let the user
deal with rows that fail validation in the form itself.

Thanks for the heads up!
François

On 9 fév, 16:37, Matt Jones <[email protected]> wrote:
> On Feb 8, 2010, at 11:34 PM, François Beausoleil wrote:
>
> > Hi!
>
> > I'm offering an import form for my users.  The import model itself
> > isn't a real ActiveRecord model.  How can I benefit from all of
> > DRYML's goodies, without using a hobo_model?
>
> BTW: I've implemented something much like this, where admin-ish users  
> can upload a CSV file of user info and create a bunch of regular  
> users. No idea if that's exactly what you're going for here, but anyway.
>
> The setup I ended up using in my app was a two-step process:
>
> - upload the file.
>
> - "process" the file. In my app, I was importing from variable-format  
> CSV (no consistency of column headings / order), and so this was  
> useful since I could analyze the actual file to find the real column  
> names. The "process" action looks up the column names from the  
> uploaded CSV and then lets the user indicate how they map to the  
> columns the system expects. The form looks a little like this:
>
> first_name => (dropdown, showing actual headers and the first  
> corresponding bit of data)
> ... repeat for a bunch more fields ....
>
> No idea if your system needs that much flexibility, but the "process"  
> action might also be a good place to tie in the "dryrun" stuff your  
> code hints at.
>
> There's an optional third step, where any row that didn't pass  
> validation (or the remainder of the CSV, if it's malformed) is spit  
> back into a new file along with the validation errors. This has helped  
> my client figure out what's wrong with their data a number of times...
>
> To wrap up, the upside to this method is that the upload/process stuff  
> is all pretty standard Rails; the file is a standard model  
> (attachment_fu, I think), etc.
>
> It also avoids having to upload the file twice - it appears (at first  
> glance) like your method will need a user to upload the file once for  
> the "dry run" and then again for the real thing. Not a big deal for  
> small files, but a hassle nonetheless - especially since file upload  
> fields don't typically retain their values when you send a user back  
> to a form.
>
> Hope this helps.
>
> --Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to