Slide 20
Slide 20 text
# db/fixtures/01_books.rb
require 'csv'
books = []
CSV.foreach('db/fixtures/books.csv').with_index do |row, i|
next if i.zero?
books << {
id: row[0],
title: row[1],
author: row[2],
created_at: row[3],
updated_at: row[4]
}
end
Book.insert_all books
# db/fixtures/books.csv
id,title,author,created_at,updated_at
1,ֶͷ͢͢Ί,་٢,2022-06-20 10:44,2022-06-20 10:44
2,ҏ౾ͷགྷΓࢠ,߁,2022-06-20 10:44,2022-06-20 10:44
CSV͔ΒSeed͍ͯ͠Δ
ϞσϧΛൃݟ👀