Search

Chaps

Sweet sweet memories

Blather

Uptime verified by Wormly.com

Cairns to Alice Springs

Alice and I are riding our bikes to Alice Springs from Cairns. We have a bit of a travel blog, Flickr photos and our funny little SPOT GPS tracker page.

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
  • **bold text**
  • *italicized text*
  • > This text is blockquoted
  • * This is an unordered list item
  • 1. This is an ordered list item
  • [Link Text](http://www.example.com/)
  • `code item`

Cairns to Alice Springs

0.062 seconds