Wednesday, 21 March 2007

Rails Fixtures with Legacy Database

My setup was:

MySQL Table name: TABLENAME
Rails Model name: TableName

  1. The fixture file has to be TABLENAME.yml (not case sensitive)
  2. fixtures() takes the symbol name of the Model, in this case :tableName (note the first lowercase letter) This is the bit that drove me mad - i was writing fixtures :TableName which appeared to work, but then the test failed if I tried TableName(:foo)
  3. Now you can write tableName(:foo)

No comments: