We all know that standard Rails fixtures suck – they were good at the time of their invention, mainly because nothing better existed – but numerous weaknesses and problems have been mentioned since then.
While the above solutions are really great, they are quite different from standard fixtures in their philosophy, and I believe because of that some people just rolled on with the standard solution. Well, there is a new player in the town, so no more excuses.
Patterns in fixture names – Using the pattern “(owners)s\_(color)\_(make)” in conjunction with the fixture
name “Freds\_red\_Ford” unpacks owner to Fred, color to red and make to Ford.
(owners)s_(color)_(make) Freds_red_Ford: year: 1977 Eds_blue_Chevy: year: 1987 Becomes Freds_red_Ford: owner: Fred color: red make: Ford year: 1977 Eds_blue_Chevy: owner: Ed color: blue make: Chevy year: 1987
Grouping of Data – Often fixtures group cleanly- family of users, manufacturers of cars, etc. Lite fixtures lets you nest data, so scoped values are propigated inward.
red_fords: make: ford color: red mustang: owner: freddy taurus: owner: freddy Becomes: mustang: make: ford color: red owner: freddy taurus: make: ford color: red owner: freddy
I really think this improvement should make it to the Rails core – unless they are replacing the fixtures with something radically different.