LoginSignup
0
0

More than 3 years have passed since last update.

CSVをアップロードしてデータベースに入れる(備忘録)

Posted at

基本のやり方はコチラ
https://qiita.com/junara/items/183aaff5e5b77ec1c679#%E3%83%A2%E3%83%87%E3%83%AB

1、rails console を立ち上げる

2、Supporter.simple_import(path: 'db/test_mail_list.csv', col_sep: ',')
  ↑こちらを入力
  Supporterの部分は、必要に応じて変更。User、Eventなど。

3、Supporter.where(event_id 19).destroy_all
  ↑入力全部消すとき

4、test_mail_list.csvのファイルの場所は dbフォルダ直下

上記で簡単に操作できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0