Не удалось запустить команду rake с помощью smarter_csv

Я создал задачу rake для импорта csv с smarter_csv.

Выдает следующее сообщение, я добавил весь код ошибки, если это помогает:

rake import_csv:import_csv
Digest::Digest is deprecated; use Digest
I, [2017-03-01T11:46:08.551994 #7029]  INFO -- : ** [Raven] Raven 0.14.0 configured not to send errors.
rake aborted!
NoMethodError: undefined method `close' for nil:NilClass
/home/my_user/.rvm/gems/[email protected]_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:223:in `ensure in process'
/home/my_user/.rvm/gems/[email protected]_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:223:in `process'
/home/my_user/my_app/lib/tasks/import_csv.rake:7:in `block (2 levels) in <top (required)>'
/home/my_user/.rvm/gems/[email protected]_app/bin/ruby_executable_hooks:15:in `eval'
/home/my_user/.rvm/gems/[email protected]_app/bin/ruby_executable_hooks:15:in `<main>'
Errno::ENOENT: No such file or directory @ rb_sysopen - /csv_imports/pacientes.csv
/home/my_user/.rvm/gems/[email protected]_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:23:in `initialize'
/home/my_user/.rvm/gems/[email protected]_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:23:in `open'
/home/my_user/.rvm/gems/[email protected]_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:23:in `process'
/home/my_user/my_app/lib/tasks/import_csv.rake:7:in `block (2 levels) in <top (required)>'
/home/my_user/.rvm/gems/[email protected]_app/bin/ruby_executable_hooks:15:in `eval'
/home/my_user/.rvm/gems/[email protected]_app/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => import_csv:import_csv
(See full trace by running task with --trace)

Это код задачи грабли:

namespace :import_csv do
  desc "import csv file"
  task import_csv: :environment do
    require 'smarter_csv'
    filename = '/csv_imports/file.csv'
    options = {:key_mapping => { :downcase_header => true }}
    SmarterCSV.process(filename, options) do |array|
      CsvImports.create( array.first )
    end
  end

end

Ответ 1

Это решается просто с точки. маршрут.

 ./csv_imports/file.csv