Skip to content

Latest commit

 

History

History
31 lines (17 loc) · 1.23 KB

DB_Seeds.md

File metadata and controls

31 lines (17 loc) · 1.23 KB

SEEDS

Extract Content from Seeds into a Google Sheet

Solution

The concept is that you create one sheet for each model. Convert the sheet as a JSON and create instance out of this JSON

Exemple of google sheets

Links to the seed file

A quick tutorial to change your google sheet as a JSON

The json url should look like:

https://spreadsheets.google.com/feeds/list/keyOfTheGoogleSheet/public/values.alt=json

https://spreadsheets.google.com/feeds/list/1CW_PI1spEoZ-e87TD9TvwVBz1-n2etWw5wGufLOC9I0/1/public/values?alt=json

Database

Reference to a specific table / model:

You want to reference two times the same model in a table (user_1 / user_2)

Solution

t.references :item, foreign_key: { to_table: :items }

Stackoverflow thread

see a migration on a student project