neurodynamic
neurodynamic

Reputation: 4404

How to format YAML to specify which model to populate using yaml_db gem

I'm pretty new to this, so this is probably obvious and I'm missing something. If I have some data in a .yml file I want to populate the database with using yaml_db. How does it know what model to populate with the data? Do I name the file after the model (e.g. to populate people, person.yml) or should the data be nested under the name of the model (e.g. person: alan: etc, etc) , or something else?

Upvotes: 0

Views: 199

Answers (1)

neurodynamic
neurodynamic

Reputation: 4404

Got it thanks to normalocity's suggestion. For a Human model with a name, populating with 4 people would have YAML like this:

---
humans:
  columns:
  - id
  - name
  records:
  - - 1
    - "Billy"
  - - 2
    - "Joey"
  - - 3
    - "Sara"
  - - 4
    - "Jess"

Upvotes: 1

Related Questions