Sha256: 232c36413fe00e9339a30ec00728705f549fe3aa1dbf2b1f9c00e755c87f594b

Contents?: true

Size: 605 Bytes

Versions: 3

Compression:

Stored size: 605 Bytes

Contents

#!/usr/local/bin/ruby -w

# csv_rails_import.task
#
#  Created by James Edward Gray II on 2006-11-05.
#  Copyright 2006 Gray Productions. All rights reserved.

namespace :my_app_name do
  desc "Injects purchase.csv into the database."
  task :load_purchase => [:environment] do
    require "#{RAILS_ROOT}/vendor/faster_csv/lib/faster_csv"
    
    purchase = Purchase.create!
    
    FCSV.foreach( "#{RAILS_ROOT}/db/questions.csv",
                  :headers           => true,
                  :header_converters => :symbol ) do |line|
      purchase.line_items.create!(line.to_hash)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
glennfu-faster_csv-1.5.5.1 examples/csv_rails_import.task
rw_fastercsv-1.5.7 examples/csv_rails_import.task
rw_fastercsv-1.5.6 examples/csv_rails_import.task