Rails 2 fixtures not working

I upgraded my 1.2.6 app to 2.0.2 with all tests passing. I then rewrote
the fixtures with the new rails 2 ‘foxy fixtures’ style, e.g.
referencing fixture names instead of ids. I’m now getting a ton of
errors like the following:

ActiveRecord::StatementInvalid in ‘LineItemCache truth’
PGError: ERROR: column “line_item” of relation “line_item_caches” does
not exist
LINE 1: …item_caches (“cached_product_name”, “unit_price”,
"line_item…
^
: INSERT INTO line_item_caches (“cached_product_name”, “unit_price”,
“line_item”) VALUES (E’foo’, 1, E’li_prep_time_7’)

Looks like it’s not detecting the model relationships in this case.
Here’s the relevant fixture and model info:

line_item_caches.yml:

DEFAULTS: &DEFAULTS
cached_product_name: foo
unit_price: 1

lic1:
line_item: li1
<<: *DEFAULTS

line_items.yml:

DEFAULTS: &DEFAULTS
special_ins: asdf
unit_price: 1
quantity: 1

li1:
product: small_espresso
order: order1
user: joe
<<: *DEFAULTS

line_item.rb:

class LineItem < ActiveRecord::Base
has_one :line_item_cache, :dependent => :destroy
end

line_item_cache.rb:

class LineItemCache < ActiveRecord::Base
belongs_to :line_item
end

Funny thing is, sometimes it does pick up the names, but then I get
another wierd error where it thinks #YAML::Syck::MergeKey:0xb6f040b8
is a column name:

ActiveRecord::StatementInvalid in ‘Location hours by type’
PGError: ERROR: column “#YAML::Syck::MergeKey:0xb6f040b8” of relation
“orders” does not exist
LINE 1: …, “id”, “pickup_time”, “user_id”, “order_number”,
"#<YAML::S…
^
: INSERT INTO orders (“status”, “location_id”, “id”, “pickup_time”,
“user_id”, “order_number”, “#YAML::Syck::MergeKey:0xb6f040b8”,
“created_at”) VALUES (E’open’, 673263714, 1026752367, E’2008-05-07
03:40:00’, 910594905, 12345, E’— &id001
status: open
pickup_time: 2008-05-07 03:40:00
!ruby/object:YAML::Syck::MergeKey ? {}
: *id001
location: joes_coffee
‘, E’2008-05-07 03:18:05.670587’)

Anyone had a similar problem?

Hi –

On Sat, 12 Jul 2008, Chris S. wrote:

LINE 1: …item_caches (“cached_product_name”, “unit_price”,
"line_item…
^
: INSERT INTO line_item_caches (“cached_product_name”, “unit_price”,
“line_item”) VALUES (E’foo’, 1, E’li_prep_time_7’)

Looks like it’s not detecting the model relationships in this case.

Are you sure you’ve migrated the test database completely?

David

–
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails July 21-24 Edison, NJ
Advancing With Rails August 18-21 Edison, NJ
See http://www.rubypal.com for details and updates!

Yes the test db is indeed current. Fixtures were loading and my tests
were passing before I changed the fixtures.