Rails fixtures — how do you set foreign keys?

前端 未结 2 1993
傲寒
傲寒 2020-12-16 10:37

I\'m reading about Rails fixtures in this guide (thanks, trevorturk). It appears you define classes in a Yaml file and they\'re automatically loaded into the test

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 11:02

    Additionally, if you wish to have a many to many association ( HABTM ) you just give an array for the association in the fixture:

    # recipes.yml
    chicken_soup:
      cookbooks: [my_recipes, another_recipe]
    

提交回复
热议问题