0

在 Mac 下上传文件时遇到问题。在 windows 开发环境下没问题,在 ubuntu prod 下没问题,但是当我尝试上传和解析文件时,在 Mac os 10.6.8 下抛出这个:

ProductsController#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
4

0 回答 0