Rake don't know how to build task?
Posted
by Schroedinger
on Stack Overflow
See other posts from Stack Overflow
or by Schroedinger
Published on 2010-04-19T09:50:15Z
Indexed on
2010/04/19
9:53 UTC
Read the original article
Hit count: 415
Using a rake task to import data into a database: file as follows
namespace :db do
desc "load imported data from csv"
task :load_csv_data => :environment do
require 'fastercsv'
require 'chronic'
FasterCSV.foreach("input.csv", :headers => true) do |row|
Trade.create(
:name => row[0],
:type => row[4],
:price => row[6].to_f,
:volume => row[7].to_i,
:bidprice => row[10].to_f,
:bidsize => row[11].to_i,
:askprice => row[14].to_f,
:asksize => row[15].to_i
)
end
end
end
When attempting to use this, with the right CSV files and the other elements in place, it will say Don't know how to build task 'db:import_csv_data'
I know this structure works because I've tested it, I'm just trying to get it to convert to the new values on the fly.
Suggestions?
© Stack Overflow or respective owner