lib/csvsfolder. In the example below, the file is called
Transaction. The column names in your model don't have to match up exactly with the headings in the CSV.
rails slurp:transactionswhich will slurp the data from
real_estate_transactions.csvand put it in our database.
lib/tasks/slurp.rakethat looks like this:
task transactions: :environment doand the first
rails slurp:transactionsyou should see a wall of text representing your CSV data. It's a first step, but we've still got a lot of work to do.
rails slurp:transactionsat the end of each step
:headers => trueoption tells the parser that the first line in the file has column headings in it, not a row of data.
:headers => trueoption in our previous step.