Closed gregorymark closed 6 years ago
Almost doesn't sound like it made it easier hehe. But thank you!
You might have found something here. The addon gives you a post
as well as a page
model. Behind the scenes these two both extend from the same addon/models/post.js.
Can you reproduce it in the demo app?
Hehe, I'd definitely still be working things out if I didn't have the addon!
So when you say reproduce it in the demo app I've tried installing this as my app, but I can't seem to get past a load of errors (not finding files and so on). Is that what you mean?
Almost. If you git clone
this repository and run ember serve
it'll serve the "dummy app" (same as you linked).
I thought if you can reproduce the error there as well it would be easier to track it down :)
Right, yes. Easier than I thought :)
It's having the same problem there. Categories load because they're using a different model, but requests using the same model use the first model name requested.
If I change the models defined in app/models
as follows
import Post from 'ember-wordpress/models/post';
export default Post.extend({
});
then it works and requests the correct URL.
@gregorymark mind verifying that it works here? https://github.com/oskarrough/ember-wordpress/pull/44. Then I can merge and release a new version.
@oskarrough yep that's working.
Awesome work on this addon, it's made my life much easier!
I was having a real issue working out why Ember was caching my first loaded model, despite changing routes in my build. It seems that because I was not defining models in my app (as in the demo) but relying on the addon defined models, the models were all being initially cached as having the same model type. Therefore subsequent calls to the API were building the same URL from the same model name, though with the correct parameters. The result was that it was returning e.g. pages when I wanted posts if the first route loaded was a page and the second to posts.
Adding models in my app as simply as
solved the problem, though using
everywhere didn't.
I'm pretty new to Ember so it's possible I'm making a rookie error here or elsewhere (though I built a minimal use-case as close to the demo as I could get and was still having the same issue), but I noticed that the demo build uses a pretty old version of Ember - is that behaviour that's changed? Is it worth updating the demo build? It certainly took me a while to track down!
For the record this is how I'm loading my /about route
Anyway, working now, mostly to save time for anyone else who's having this issue, unless it's worth updating the demo environment if I'm correct.