# Arrays in test fixtures

**URL:** <https://www.ruby-forum.com/t/arrays-in-test-fixtures/114290>\
**Category:** Rails\
**Created:** [September 10, 2007, 11:44pm UTC](https://www.ruby-forum.com/t/arrays-in-test-fixtures/114290 "2007-09-10T23:44:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [September 10, 2007, 11:44pm UTC](https://www.ruby-forum.com/t/arrays-in-test-fixtures/114290/1 "2007-09-10T23:44:53Z")

</div>

I have a model called role which has many rights. However, I’m having  
trouble expressing this in my text fixture:

administrators:  
id: 1  
name: Administrators  
rights: How do I add an item to the rights array here?

---

<div class="post-metadata">

**Author:** ![eggie5](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7c8e57/32.png) [@eggie5](https://www.ruby-forum.com/u/eggie5)\
**Post date:** [September 11, 2007, 8:51am UTC](https://www.ruby-forum.com/t/arrays-in-test-fixtures/114290/2 "2007-09-11T08:51:41Z")

</div>

eggie5 wrote:

> I have a model called role which has many rights. However, I’m having  
> trouble expressing this in my text fixture:
> 
> administrators:  
> id: 1  
> name: Administrators  
> rights: How do I add an item to the rights array here?

You need to create the rights in a fixture on it’s own and then set the  
administrator\_id in that fixture. Just like you would if you were  
creating the rows in the database by hand.

–  
Cheers,

- Jacob A.
