undefined метод `path'для"test.csv":String Вы имели в виду? pathmap

При импорте CSV я сталкиваюсь с этой проблемой

`def self.import(file)
    binding.pry
    CSV.new(file.path, headers: true) do |row|
    puts "upload"
    end     
end`

0 ответов

Должен быть определен 'require csv ' или иным образом

class User < ApplicationRecord
  require 'csv'
  #file = File.expand_path('csv_file.csv', __FILE__)
  def self.import(file)
    CSV.foreach(file.path,headers:true) do |row|
      User.create! row.to_hash
    end
  end
end
Другие вопросы по тегам