miragejs / ember-cli-mirage

An Ember Addon to easily add Mirage JS to your Ember app.
http://ember-cli-mirage.com
MIT License
863 stars 439 forks source link

Provide additional information on fixture associations #1064

Closed nyon closed 6 years ago

nyon commented 7 years ago

I'm relatively new to ember-cli-mirage and got stuck with the convention, that belongsTo associations need to be suffixed with Id in order to work. I think other users could stumble upon that same mistake in the future. I thought

DS.Model.extend({
  fooFix: DS.belongsTo()
});

meant

export default [
  {
    id: 1,
    fooFix: 1
  }
];

in your fixture specification. This was not the case. I had to append the Id suffix.

I propose to add a description to the fixture chapter (http://www.ember-cli-mirage.com/docs/v0.3.x/fixtures/) in order to clarify this.

samselikoff commented 7 years ago

@nyon Thank you for posting — I agree that's confusing!

We have some docs in the "Seeding your database" section of the guide here: http://www.ember-cli-mirage.com/docs/v0.3.x/seeding-your-database/#relationships-with-fixtures. But I absolutely agree they should be added to the Fixtures API reference doc as well.

Would you mind helping me out with this? If you go to the Fixtures page and click "Improve this page" at the top right, you'll be able to propose a change to the guide. Just a few short examples of setting belongsTo and hasMany IDs should be sufficient.

samselikoff commented 6 years ago

https://github.com/samselikoff/ember-cli-mirage/commit/158535070db222bfb0c22df656cb13577e3d65b7 closes