在Mac下上传文件时遇到问题。在windows dev环境下它很好,在ubuntu prod下可以,但是当我尝试上传和解析文件时,在Mac OS 10.6.8下抛出它:
产品控制器#import_adjust
中的Errno :: ENOENT没有这样的文件或目录 - / var / folders / v8 / v8lBbdWcGJmntpbJRzGcfU +++ TI / -Tmp- / RackMultipart20120824-71301-1aqop0s
这是一个表格:
<%= form_for :upload, :html => {:multipart => true}, :url => {action: "upload"} do |f| %>
<%= f.file_field :my_file %>
<%= f.submit "Upload" %>
<% end %>
这是一个代码:
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