Skip to content

Instantly share code, notes, and snippets.

@Jeffrey-Fazal
Jeffrey-Fazal / gist:6941e5e8fee2831579d187d05d2c14f8
Created January 18, 2023 19:06 — forked from arjunvenkat/gist:1115bc41bf395a162084
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.