What are Rails Fixtures Good for Anyway?

15 Jun 2007

(This is the second of three posts on Rails fixtures)

I like using fixtures for setting up a development environment. Applications need data in the db to function so what most teams do is pass around a database, or two, or five. A new person joins the project and he/she gets a dump from one of the devs, imports it and goes to work. What happens when you screw up your db by:

Well, you need to get somebody else’s db. Which maybe in a bad state and it definitely doesn’t have the same data you’re used to because they’ve been changing it a lot.

But if you have a bunch of fixtures checked in to source control, you can always go back to a base state. Anytime something is acting wacky and you think it might be a data problem (which happens more and more as the app gets older) wiping the db is simple and easy. Also, everyone has the same data so you can collaborate easier.

Next: How to migrate fixtures.