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

Model.relatedTypes documentation incorrectly describes classes instead of strings #8020

Closed
Elawphant opened this issue Jul 6, 2022 · 7 comments
Labels
good-first-issue 🏷️ doc This PR adds/improves/or fixes documentation

Comments

@Elawphant
Copy link

There is a wrong example in api docs https://api.emberjs.com/ember-data/4.4/classes/Model/properties/relatedTypes?anchor=relatedTypes
Doc shows in the example that this method returns the related model classes, while in reality it returns their small-case names.
See the correction below.

import Model, { belongsTo, hasMany } from '@ember-data/model';

export default class BlogModel extends Model {
   @hasMany('user') users;
   @belongsTo('user') owner;

   @hasMany('post') posts;
 }
import { get } from '@ember/object';
import Blog from 'app/models/blog';

let relatedTypes = Blog.relatedTypes');
//=> [ User, Post ] <-- this line

instead it returns ['user', 'post']

@acorncom
Copy link
Contributor

@Elawphant would you be able to send in a doc fix for that? Would love to get that fixed

@Elawphant
Copy link
Author

Give me the link, I would gladly do that.

@acorncom
Copy link
Contributor

@Elawphant you bet. Click on https://api.emberjs.com/ember-data/4.4/classes/Model/properties/relatedTypes?anchor=relatedTypes, browse to where it is defined and you should be able to edit the source

@runspired runspired changed the title Wrong documentation Model.relatedTypes documentation incorrectly describes classes instead of strings Jul 15, 2022
@runspired
Copy link
Contributor

It looks like the docs for Model.inverseFor also incorrectly specifies the class as the type on the relationship meta object. Likely this same mistake was made a number of places, probably this was true at one time in the very early days of ember-data.

@Elawphant
Copy link
Author

@runspired I believe so, too.
@acorncom github is not letting me do pull request to fix it.

@runspired
Copy link
Contributor

fixed in #8440 (thanks @Shubhi-73). I'll leave this open for Model.inverseFor fix as well.

@runspired runspired added 🏷️ doc This PR adds/improves/or fixes documentation and removed Good for New Contributors labels Sep 10, 2023
@runspired
Copy link
Contributor

fixed as part of #9292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good-first-issue 🏷️ doc This PR adds/improves/or fixes documentation
Projects
Archived in project
Development

No branches or pull requests

3 participants