# Rails 2 fixtures not working

**URL:** <https://www.ruby-forum.com/t/rails-2-fixtures-not-working/142852>\
**Category:** Rails\
**Created:** [July 12, 2008, 4:32am UTC](https://www.ruby-forum.com/t/rails-2-fixtures-not-working/142852 "2008-07-12T04:32:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 12, 2008, 4:32am UTC](https://www.ruby-forum.com/t/rails-2-fixtures-not-working/142852/1 "2008-07-12T04:32:48Z")

</div>

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:

1. 

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:

1. 

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?

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 12, 2008, 4:37am UTC](https://www.ruby-forum.com/t/rails-2-fixtures-not-working/142852/2 "2008-07-12T04:37:04Z")

</div>

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](http://www.rubypal.com) for details and updates!

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [July 12, 2008, 5:02am UTC](https://www.ruby-forum.com/t/rails-2-fixtures-not-working/142852/3 "2008-07-12T05:02:22Z")

</div>

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