CSV upload button with validation

Hi all,

i urgently need help for my first RoR app which should be running already. My app is a shop database (http://ewallshops.heroku.com/) made with Heroku. Entering shops manually already works fine. Data entered is checked for correctness of email adress and uniqueness of the shop name.

Now I need to add a button to enable front-end users to upload .csv shop data that, during upload, also should pass the checks. In case of errors, the data items containing them should be shown. The others (without errors) shall be integrated into my database with continuing ids (not those from the csv-file).

Some things about Heroku: As far as I know it uses Rails 2.0.2 and postgresql as database.

Thanks in advance! Daniel

Sorry to stress, but I really need help with this. I've already been looking this forum and also tried several solutions, but none of them worked. Please help me if you can. thx

How far have you gotten?

There are a few things you need to implement:

1. Form which allows the user to upload the file (http:// manuals.rubyonrails.com/read/chapter/57) 2. Controller method that imports the data

This method needs to iterate over each line, splitting the fields on ',' and create the objects. new_object = Object.new(blah, blah)

You store the failed objects in an array failed << new_object unless new_object.save

3. If failed contains entries you need to redirect to a form presenting the items to be corrected if failed.length > 0 redirect_to :action => 'fix_records'

tip : u might want to use the valid? method of the model.

new_item = Item.new(:name=>..., bla bla)

failed_items =

if new_item.valid? ..... do something .... else failed_items << new_item end