Errno :: ENOENT:没有这样的文件或目录@ rb_sysopen

时间:2018-07-27 15:06:40

标签: ruby-on-rails ruby

我正在与Ruby on Rails一起做一个项目,试图建立一个电子商务杂货店,因此创建了一些不需要我的db/seed.rb文件的数据。

我创建了一个CSV文件,其中包含产品,SKU,类别,站点名称,价格等信息,然后将以下代码放入我的seed.rb文件中:

require 'csv'
CSV.foreach(Rails.root.join("db/seeds_data/Store.csv"), headers: true) do |row|
  Store.find_or_create_by(upc: row[0], article_name: row[1], product_category_name: row[2],
  super_product_category_name: row[3], category_code: row[4], category_name: row[5],
  trading_area_name: row[6], ranged_articles_tw: row[7], site_name: row[8], price: row[9])
end

然后我尝试运行rails db:seed,它返回此错误:

Errno::ENOENT: No such file or directory @ rb_sysopen - /home/ec2-user/environment/grocerystore/db/seeds_data/store.csv
/home/ec2-user/environment/grocerystore/db/seeds.rb:2:in `<main>'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/usr/local/rvm/gems/ruby-2.4.1/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
bin/rails:4:in `<main>'

0 个答案:

没有答案