guides-source
guides-source copied to clipboard
Re-use Ember Data examples instead of changing types
Copied over from https://github.com/emberjs/ember.js/issues/17956 created by @pink-cupcakes:
I wanted to provide feedback on the data models documentation: I would recommend starting in the order of going through CREATE before going through FIND methods. There's nothing to find if you follow the documentation, for example:
this.store.findRecord('blog-post', 1) - returns a 404 for me
Secondly, this wouldn't be such an issue if the examples were consistent. The example for findRecord above is blog-post, but then if you go to the create, update, delete documentation, we have:
store.createRecord('post', { title: 'Rails is Omakase', body: 'Lorem ipsum' });
Or we have a Person model:
person.get('isAdmin'); // => false person.get('hasDirtyAttributes'); // => false person.set('isAdmin', true); person.get('hasDirtyAttributes'); // => true person.changedAttributes(); // => { isAdmin: [false, true] }
Which outside of this chunk, is never referenced anywhere - the example lives in isolation, leaving your mental model of how these methods can interact, incomplete.
These are just feedback from someone new to Ember and trying to figure this out as quickly as possible to POC ideas. Even if the documentation is continuous (borrowing from examples from previous sections), the documentation should be strong enough to stand in isolation.
Comment by @runspired:
I believe we should move this issue to the guide's website?
In general I agree with
- cohesive examples being a 👍
- an example with some sort of mock being 👍 (you have this same problem with
createRecord().save()fwiw)
Querying data is the more common case than creating new data, so starting with something such as findRecord I believe is still the way to go, so long as the examples build on each other in a nice way and someone going through the guide can spike something to see it in practice.