# You must pass an array of records to set a hasMany relationship Error

**URL:** https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297
**Category:** Ember Data
**Created:** [November 20, 2021, 12:22pm UTC](https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297 "2021-11-20T12:22:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Szabo\_Bogdan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/szabo_bogdan/32/16959_2.png) [@Szabo\_Bogdan](https://discuss.emberjs.com/u/Szabo_Bogdan)
#### Post date: [November 20, 2021, 12:22pm UTC](https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297/1 "2021-11-20T12:22:00Z")

</div>

I just upgraded ember from v3.27.0 to v3.28.4 and ember data from 3.27.1 to 3.28.3 and some of my tests are failing with the error: `You must pass an array of records to set a hasMany relationship` in places that before it worked fine. For example:

```auto
                <Input::Icons::ListToggle
                  @list={{@model.campaign.optionalIcons}}
                  @value={{@model.answer.icons}}
                  @onChange={{this.changeIcons}}
                />

```

in this case `model.answer.icons` is an ember data has many relation which returns a promise. When I tried to do assign this value to another ember data model like this it fails:

```auto
this.model.answer.icons = value;

```

does anyone have any thoughts about how to fix this? Is this a new behavior of ember and ember data or is it a bug?

---

<div class="post-metadata">

### Author: ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)
#### Post date: [November 22, 2021, 4:56pm UTC](https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297/2 "2021-11-22T16:56:15Z")

</div>

In the case where you’re setting it what is `value`?

```auto
this.model.answer.icons = value;

```

---

<div class="post-metadata">

### Author: ![Szabo\_Bogdan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/szabo_bogdan/32/16959_2.png) [@Szabo\_Bogdan](https://discuss.emberjs.com/u/Szabo_Bogdan)
#### Post date: [November 24, 2021, 9:12am UTC](https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297/3 "2021-11-24T09:12:18Z")

</div>

the `value` is the resolved `@model.campaign.optionalIcons`

---

<div class="post-metadata">

### Author: ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)
#### Post date: [November 24, 2021, 4:29pm UTC](https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297/4 "2021-11-24T16:29:08Z")

</div>

Hmmm that does seems strange. If I was debugging this I’d probably start by putting a breakpoint in and inspecting those objects (`this.model.answer.icons` and `value`) to make sure they are what you expect. You could also try using something like:

```auto
this.model.answer.icons.pushObjects(value);

```

to see if that works or gives you any different errors which could point you in the right direction.

---

<div class="post-metadata">

### Author: ![runspired](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/runspired/32/18654_2.png) [@runspired](https://discuss.emberjs.com/u/runspired)
#### Post date: [December 28, 2021, 6:06am UTC](https://discuss.emberjs.com/t/you-must-pass-an-array-of-records-to-set-a-hasmany-relationship-error/19297/5 "2021-12-28T06:06:11Z")

</div>

If you get a better reproduction could you open an issue?
