Rails fixtures — how do you set foreign keys?
问题 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 DB -- cool. But if you want to specify that this recipe belongs to that cookbook (or whatever) how do you do that? Are you supposed to specify the values for cookbook.id and recipe.cookbook_id by hand in the Yaml code? (Just a guess -- the guide doesn't show anything like that.) Or is there a more suitable way? 回答1: You should use