ruby - Error While Importing CSV Document - 0 Records Get Added -


i getting output 0 records added when trying import csv file database. controller code :-

            def add         if request.post?           @parsed_file=csv::reader.parse(params[:dump][:file], :headers => true)           n=0           @parsed_file.each |row|           c=student.new           c.admission_no=row[0]           c.class_roll_no=row[1]           c.admission_date=row[2]           c.first_name= row[3]             if c.save               n=n+1               gc.start if n%50==0             end           end           flash[:notice]="csv import successful, #{n} new records added data base"           redirect_to :controller=>"data_import", :action=>"index"         end       end     end  

my ruby version 1.8.7

student table inserting data.

can 1 me out.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -