Kryptyk Fysh
2010-May-09 17:52 UTC
Problem using FasterCSV on Import: Can''t convert Tempfile to string
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.