Hi,
I'm trying to import a CSV file using fasterCSV and keep getting this
error when trying to import the file.
The parameters are passed from this view:
<% form_for :dump, :url => { :controller => 'mots', :action =>
'mot_csv_import' }, :html => { :multipart => true } do |f| %>
<p>
<%= f.label :file, 'Select file to import' %><br />
<%= f.file_field :file -%>
</p>
<p>
<%= submit_tag "Submit" %>
</p>
<% end %>
To this action:
def mot_csv_import
header_row = true
row_number = 0
FasterCSV.foreach(params[:dump][:file]) do |row|
if not header_row
Mot.create(
:vrm => row[4],
:is_active => 0,
:is_new => 1)
row_number += 1
GC.start if row_number%50 == 0
header_row = nil
end
end
redirect_to :controller => 'mots', :action => 'index'
end
Can anyone advise me where I'm going wrong, please?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.