Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get ember-data hasMany to work. #2217

Open
rpringadi opened this issue Jul 29, 2021 · 2 comments
Open

Cannot get ember-data hasMany to work. #2217

rpringadi opened this issue Jul 29, 2021 · 2 comments

Comments

@rpringadi
Copy link

Bug or question

Hi!
I'm trying to get ember-data @hasMany, one to many relationship to work - but keep failing.
Then intention:
The scan-phase API will return a JSON object, with many phase objects.

If I put a debugger in the mirage/scenarios/default.js, mirage db seems to have a good data.

server.db.dump()

Screen Shot 2021-07-29 at 1 47 05 AM

But then the error happened.

Error message:

Mirage: You're trying to create a scan-phase model and you passed in "[object Object],[object Object]" under the phases key, but that key is a HasMany relationship. You must pass in a Collection, PolymorphicCollection, array of Models, or null.

Screen Shot 2021-07-29 at 2 11 02 AM

Diff from ember-cli-mirage-boilerplate
rpringadi/ember-cli-mirage-boilerplate@b96acba

Env
ember-cli: 3.10.1
node: 14.16.1
os: darwin x64

Please advice what went wrong if possible. Thanks in advance.


If possible, please use the Mirage Boilerplate to demonstrate your issue or bug:

  1. Visit the Ember CLI Mirage Boilerplate repo

  2. Click Fork

  3. Clone your fork locally, checkout a new branch, reproduce your issue and push

  4. Link to your branch in your issue

https://github.com/rpringadi/ember-cli-mirage-boilerplate/tree/onetomanyrelationship
branch: onetomanyrelationship

@cah-brian-gantzler
Copy link
Collaborator

It looks like this error is actually happening in mirage but I cant tell when from the information. In Mirage you defined a route, could you post what this route looks like?

Also, this functionality has been extracted to MirageJS and this issue should really be opened there. https://github.com/miragejs/miragejs/issues

@SergeAstapov
Copy link
Collaborator

@rpringadi it would really help if you could came up with minimal reproduction so we can chase the root cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants