Ruby on Rails: loading seed data from a YAML file

后端 未结 4 946
礼貌的吻别
礼貌的吻别 2020-12-28 18:04

How do I use a YAML file instead of seeds.rb to load the initial data into a database?

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-28 18:13

    I built this script to handle exactly this issue, while keeping seeds yaml files separate to tests.

    It has namespace support, and will automatically find records when you supply just an id

    https://gist.github.com/x9sim9/78405f13b698b87ab7b234ea793399ca

提交回复
热议问题