Heroku file upload problem

前端 未结 5 1725
故里飘歌
故里飘歌 2020-12-15 14:53

I\'ve been having a problem uploading a CSV file to Heroku and processing it. It works fine in my local environment. Just do be clear, I don\'t need to save the file on Hero

5条回答
  •  死守一世寂寞
    2020-12-15 15:19

    I am still suck with this problem. I tried the solution given here to be able to do a csv file upload and then parse it to fill my DB through acive record. I have the following code:

    file = IO.read(params[:file].tempfile.path)
        FasterCSV.new(file, :headers => true).each do |row|
             # my parsing logic
        end
    

    The code just works perfect in the local but does not work at all in Heruko. I get error and all that I could see in the heruko logs is this:

    Started POST "/projects/1/upload_pivotal_csv" for 122.172.25.106 at 2012-03-23 07:45:59 +0000 2012-03-23T07:46:00+00:00 app[web.1]: 2012-03-23T07:46:00+00:00 app[web.1]: NotImplementedError (Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine.): 2012-03-23T07:46:00+00:00 app[web.1]: app/controllers/projects_controller.rb:17:in `upload_pivotal_csv' 2012-03-23T07:46:00+00:00 app[web.1]: 2012-03-23T07:46:00+00:00 app[web.1]: 2012-03-23T07:46:00+00:00 heroku[router]: POST castletrack.herokuapp.com/projects/1/upload_pivotal_csv dyno=web.1 queue=0 wait=0ms service=783ms status=500 bytes=728 2012-03-23T07:46:00+00:00 app[web.1]: Processing by ProjectsController#upload_pivotal_csv as HTML 2012-03-23T07:46:00+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"sBmRWpGP3q9Hu7O2cMlmnGTByaTXValxYHw5+cFoSw0=", "file"=>#>, "commit"=>"Import", "id"=>"1"} 2012-03-23T07:46:00+00:00 app[web.1]: Completed in 406ms

    I am sure it has something to do with the ruby version. I am using ruby 1.8.7 locally and its a rails 3 application. I am not sure what ruby version is there on heruko. But I can tell that I am using ceder stack.

提交回复
热议问题