I am trying to insert data via csv to database. This is my controller code
require 'csv'
def index
end
def add
@filename=CSV::Reader.parse(params[:dump][:file])
n=0
CSV::foreach(@filename, :headers => true) do |row|
Student.new(row.to_hash.symbolize_keys).save
n=n+1
end
flash.now[:message]="CSV Import Successful, #{n} new records added to data base"
end
Now when i am inserting a csv file i am getting the error
**can't convert CSV::IOReader into String**
My ruby version is 1.8.7
Any help will be appreciated.