문제

I have downgraded from Rails 3.2.11 to Rails 2.3.11 and I am having trouble accessing the tempfile when my csv file is being uploaded to the server.

It breaks on the code when I call

tmppath = csv.tempfile.to_path.to_s

And here is the trace in my server logs..

Processing YoloController#createByCSV (for 10.1.109.132 at 2013-03-08 10:57:11) [POST]
  Parameters: {"csv"=>#<File:/var/folders/5g/xxxxxxxxx/T/RackMultipartxxxxxxx-xxxxxx-81xb7d-0>}

NoMethodError (undefined method `tempfile' for #<Tempfile:0x10c0f8ce8>):
  app/controllers/yolos_controller.rb:67:in `createByCSV'
  vendor/bundle/ruby/1.8/gems/actionpack-2.3.11/lib/action_controller/base.rb:1333:in `send'

Any ideas would be greatly appreciated.

도움이 되었습니까?

해결책

Judging by the error and the documentation for ruby 1.8. csv is already a Tempfile, call path direclty on it: csv.path.to_s

http://ruby-doc.org/stdlib-1.8.7/libdoc/tempfile/rdoc/Tempfile.html#method-i-path

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top