# Label Reference of Fixtures

**URL:** <https://www.ruby-forum.com/t/label-reference-of-fixtures/177265>\
**Category:** Rails\
**Created:** [October 14, 2009, 10:56am UTC](https://www.ruby-forum.com/t/label-reference-of-fixtures/177265 "2009-10-14T10:56:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stallion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Stallion](https://www.ruby-forum.com/u/Stallion)\
**Post date:** [October 14, 2009, 10:56am UTC](https://www.ruby-forum.com/t/label-reference-of-fixtures/177265/1 "2009-10-14T10:56:10Z")

</div>

Hi,…

I am having trouble with label reference in fixtures…

I have two fixtures like this :

### cars.yml

one:  
name: Ferari  
two:  
name: Volvo

### drivers.yml

one:  
name: Stall  
car: Ferari

‘Drivers’ table have a ‘belongs\_to’ clause to the ‘cars’ table, vice  
versa with ‘has\_many’

Evertime i am running my test, and access the ‘drivers(:one).car’, I  
always get nil result.

Can some one tell me where my mistake?

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![Stallion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Stallion](https://www.ruby-forum.com/u/Stallion)\
**Post date:** [October 14, 2009, 10:57am UTC](https://www.ruby-forum.com/t/label-reference-of-fixtures/177265/2 "2009-10-14T10:57:21Z")

</div>

On Oct 14, 8:34 am, Stallion [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> name: Volvo
> 
> ### drivers.yml
> 
> one:  
> name: Stall  
> car: Ferari
> 
> ‘Drivers’ table have a ‘belongs\_to’ clause to the ‘cars’ table, vice  
> versa with ‘has\_many’

That should be car: one - You reference the fixture label, not any of  
the data inside it.

Fred

---

<div class="post-metadata">

**Author:** ![Stallion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Stallion](https://www.ruby-forum.com/u/Stallion)\
**Post date:** [October 14, 2009, 11:02am UTC](https://www.ruby-forum.com/t/label-reference-of-fixtures/177265/3 "2009-10-14T11:02:02Z")

</div>

2009/10/14 Stallion [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi,…
> 
> I am having trouble with label reference in fixtures…
> 
> I have two fixtures like this :
> 
> ### cars.yml
> 
> one:  
> Â name: Ferari

This should be  
Ferari:  
name: Ferari

> two:  
> Â name: Volvo
> 
> ### drivers.yml
> 
> one:  
> Â name: Stall  
> Â car: Ferari

The Ferari here refers to Ferari: above, not to the name field, which  
is a column in the db. They need not be the same.

Colin

---

<div class="post-metadata">

**Author:** ![Stallion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@Stallion](https://www.ruby-forum.com/u/Stallion)\
**Post date:** [October 15, 2009, 2:41pm UTC](https://www.ruby-forum.com/t/label-reference-of-fixtures/177265/4 "2009-10-15T14:41:08Z")

</div>

On Wed, Oct 14, 2009 at 4:55 AM, Frederick C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > two:
> 
> That should be car: one - You reference the fixture label, not any of  
> the data inside it.

And I’d recommend making the ‘ids’ more intention revealing

### cars.yml

luigis\_car:  
name: Ferari  
svens\_car:  
name: Volvo

### drivers.yml

luigi:  
name: Stall  
car: luigis\_car

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
