I have a problem while uploading a file under Mac. It was fine under windows dev environment, and ok under ubuntu prod, but throw this under Mac os 10.6.8 when I try to upload and parse a file:
Errno::ENOENT in ProductsController#import_adjust
No such file or directory - /var/folders/v8/v8lBbdWcGJmntpbJRzGcfU+++TI/-Tmp-/RackMultipart20120824-71301-1aqop0s
Here is a form:
<%= form_for :upload, :html => {:multipart => true}, :url => {action: "upload"} do |f| %>
<%= f.file_field :my_file %>
<%= f.submit "Upload" %>
<% end %>
And this is a code:
def import_adjust
case params[:commit]
when "Adjust"
@col_default = params[:col_data]
#abort @col_default.to_yaml
#update csv reader with form data, restore filters from params
when "Complete"
#all ok, read the whole file
#abort params.to_yaml
self.import_complete
return
else
@col_default = nil
end
#read first part of the file
@tmp = session[:import_file]
@csv = []
source = CSV.open @tmp, {col_sep: ";"}
5.times do
line = source.readline
if line.size>0
@line_size = line.size
@csv.push line
end
end
#generate a selection array
#selection = select_tag 'col_data[]', options_for_select([['name','name'], ['brand','brand'], ['delivery_time','delivery_time'], ['price','price']])
#@csv = [selection * line_size] + @csv
end