Skip to content

Instantly share code, notes, and snippets.

View mike-brownie's full-sized avatar
🖖

Michael Brown mike-brownie

🖖
View GitHub Profile
@mike-brownie
mike-brownie / gist:b6b9d599d20fb7e12007ec463776d2da
Created August 27, 2018 19:40 — 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.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<p>Test save for github</p>