# Error w/dynamic fixtures

**URL:** <https://www.ruby-forum.com/t/error-w-dynamic-fixtures/154263>\
**Category:** Rails\
**Created:** [November 26, 2008, 11:49pm UTC](https://www.ruby-forum.com/t/error-w-dynamic-fixtures/154263 "2008-11-26T23:49:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [November 26, 2008, 11:49pm UTC](https://www.ruby-forum.com/t/error-w-dynamic-fixtures/154263/1 "2008-11-26T23:49:59Z")

</div>

Hey All,

I’m trying to do the basic test/unit stuff & having trouble w/a dynamic  
fixture error. I’m running rails 2.0.2 on windows.

I have statuses & projects. Projects belong\_to status and so forth.

# statuses.yml ===================

active:  
name: Active  
description: MyString

# projects.yml ===================

one:  
name: Center for Health Communications Research  
abbreviation: CHCR  
description: A collection of 3 projects.  
grant\_number: 8  
status\_id: \<%= statuses(:active).id %\>  
start\_date: 2008-03-20  
end\_date: 2008-03-20

==========================================

But when I run tests I get this for output:

==========================================

1. Error: test\_truth(DomainTest): Fixture::FormatError: a YAML error  
occurred parsing C:/railsapps/collabtrac/test/fixtures/projects.yml.  
Please note that YAML must be consistently indented using spaces. Tabs  
are not allowed. Please have a look at [YAML Ain't Markup Language](http://www.yaml.org/faq.html) The  
exact error was: NoMethodError: undefined method `statuses’ for  
main:Object

==========================================

Can someone tell me what I’m doing wrong here? Is the problem that  
projects.yml is getting read in before statuses.yml? If so, how do I  
control that load order?

Thanks!

-Roy

Roy P.  
Research Analyst/Programmer  
Group Health Center For Health Studies (Cancer Research Network)  
(206) 287-2078  
Google Talk: rpardee

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [November 27, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/error-w-dynamic-fixtures/154263/2 "2008-11-27T14:00:04Z")

</div>

On Nov 26, 10:49 pm, “Pardee, Roy” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey All,

> Can someone tell me what I’m doing wrong here? Is the problem that projects.yml is getting read in before statuses.yml? If so, how do I control that load order?

That is correct and the statuses method probably isn’t even defined in  
the context you are using this in. The write way to do this is to put

status: active

in that fixture. As long as you have the status belongs\_to  
association, rails will figure out that this means that you want the  
status\_id column to have the value of the id of the status fixture  
with label ‘active’. This won’t work if your fixture for statuses  
explicitly sets an id.

Fred

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [December 1, 2008, 11:45pm UTC](https://www.ruby-forum.com/t/error-w-dynamic-fixtures/154263/3 "2008-12-01T23:45:20Z")

</div>

Sweetness–thanks!

-Roy
