|
- require 'rubygems'
- require 'csv'
- require 'dm-core'
- require 'dm-validations'
- require 'dm-timestamps'
- require 'lib/models'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- CSV::Reader.parse(File.open('../parliament-candidates.csv', 'rb')) do |row|
- p row
-
- c = Parliamentcandidate.new(
- 'forenames' => row[1],
- 'surname' => row[2]
- )
-
- c.constituency = Constituency.first( :name => row[3] )
- c.party = Party.first( :name => row[0] )
-
- unless c.save
- puts "ERROR: Failed to save candidate"
- c.errors.each do |e|
- puts e
- end
- end
- end
|