Search

Friends

Atomspheric CO2 (PPM)

Archives

Blather

Uptime verified by Wormly.com

23 July 2008

Unknown column in field list in Rails 2 fixtures

This is a problem I've come across a few times and I keep forgetting why it happens. It occurs when there is an runtime error in the model (script errors fail more loudly). This is typically a NameError, such as a bad library name or method call. The new rails fixtures need to look at the model associations to work out their magic - the mapping between association names and association foreign keys. But if the model code is bad it silently fails and the fixtures code can't work out what to do.

You'll get something like this:

$ rake db:fixtures:load
rake aborted!
Mysql::Error: Unknown column 'holiday_type' in 'field list': INSERT INTO `holiday_periods` (`holiday_type`, ...) VALUES ('school_holidays', ...)

I'd assumed it was a problem with the fixtures or the migrations. But in this case the problem was in the HolidayType class. Which is certainly not clear from the error, but on reflection not really so surprising.

Comments

No comments yet.

Leave a comment

Markdown

0.088 seconds