I am new to ruby and rails, so I am still attempting to get a handle on the syntax and structure of ruby. I am following a tutorial to import a csv file using a task and rake. I keep getting a syntax error though. I am not sure what I am missing, I do not see any difference between the example and my code.
require 'csv'
desc "Import Voters from CSV File"
task :import => [:environment] do
file ="db/my.csv"
CSV.foreach(file, :headers => true) do |row|
Voter.create{
:last_name => row[0]
}
end
(See full trace by running task with --trace)
Erics-MacBook-Air:cloudvoters ecumbee$ rake db:import --trace
rake aborted!
/Users/ecumbee/Desktop/cloudvoters/lib/tasks/import.rake:11: syntax error, unexpected tASSOC, expecting '}'
:last_name => row[0],
^
/Users/ecumbee/Desktop/cloudvoters/lib/tasks/import.rake:12: syntax error, unexpected '}', expecting '='
}
^