Michael's musings


This is a blog of
mcr at sandelman.ca

Thu, 04 Sep 2008

Foxy Fixtures in Ruby

Not obvious to me at first is that Foxy Fixtures in RoR, where you can specify a foreign key relationship by name, as in:

   ### in pirates.yml

   reginald:
     name: Reginald the Pirate
     monkey: george

   ### in monkeys.yml

   george:
     name: George the Monkey
     pirate: reginald

Depends upon the fact that you didn't include id: in the fixtures. That is, RoR is not looking into the pirates.yml file to find the "reginald" fixture, and then inserting the "id" from it in.

Rather, it's applying a hash of the string "reginald" to get the id, and so the id: of reginald had better be derived in the same way.



posted at: 11:19 | path: /ruby-on-rails | permanent link to this entry


XML


September
Sun Mon Tue Wed Thu Fri Sat
  4
       
2008
Months
Sep