Saturday, September 25, 2010

Giving up on fixtures.

This post is somewhat technical, but this problem has been giving me headaches for some time now, so I want to document my decision.

The problem has to do with setting up the databases with seed data.  Rails has something called fixtures, which allow you to create seed data for testing purposes.  This is ok, but not great for seed data which should be permanently loaded into the testing and production apps.  There is also a seed function, which does exactly this.  Ideally, you would first seed the test or dev databases, then add your fixture data so you can make your tests (test environment) or just play around (dev environment). The problem is that when you load fixtures, it deletes the seed data.  If you try to load fixtures first, then some of the  base data that the objects in the fixtures require is missing, so they are incomplete.

My solution will be to use fixtures, just for testing, which will require duplicating some of the seed data (grrrrr) and just use the seed function  for dev and production.

No comments:

Post a Comment