hardbap (owner)

Revisions

gist: 130171 Download_button fork
public
Public Clone URL: git://gist.github.com/130171.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 @headers, @data = FasterCSV.parse(@current_user.uploads.last.attachment.path, :skip_blanks => true,
                                                                  :headers => true)
     @data.each do |row|
      begin
        contact = @current_user.company.contacts.build.import(row, params[:mapping])
        
        @duplicates << row and next if contact.duplicate?
        
        contact.save!
        import_results[:accepted] += 1
      rescue Exception => e
        logger.info e
        @import_errors << row
      end
    end