CSV Import Issue

Hi, This seems to be a very small error but I cannot find any solution to this problem.. I am trying to use the CSV gem in my rails(3.2) application(ruby 1.9.3) and I am getting an error "NoMethodError". My controller is: require 'csv'

   def import       file = params[:file] <-- error       CSV.parse(file, :headers => false) do |row|           Event.new(:Ename => row[0], :Edate => row[1], :Elocation => row[2], :Edesc => row[3], :Oname => row[4], :Oemail => row[5], :Odetail => row[6])       end     end

I am getting this file from a view where the users can upload the csv file. I am getting a NoMethodError(undefined method 'nil' for nil:NilClass). My best guess is I am using this method wrong, but then my next question is how to parse the Csv data? I want to retrieve the file from my view and then parse the data into the database. How can I open the file for the same? Is the above method not correct?

The error would have told you which line and file the error was on. If you can share that information, then it may be easier to help suggest solutions.

You’ll probably have better results if you use the read method. CSV.parse is meant to be applied to a String.

From the docs: