oskarrough / ember-wordpress

The bridge between Ember.js and Wordpress
http://ember-wordpress.surge.sh
MIT License
95 stars 26 forks source link

In dummy app, directly loading route fails to load model #17

Closed sheriffderek closed 8 years ago

sheriffderek commented 8 years ago

In dummy app, directly loading route fails to load model: example: http://ember-wordpress.surge.sh/about or http://ember-wordpress.surge.sh/categories/fish

Hello world and 'posts' do seem to load - and refresh as they should: example: http://ember-wordpress.surge.sh/hello-world

oskarrough commented 8 years ago

Ah, thank you. It seems we have the page and post routes both fighting over the the root namespace. Plus the dynamic params aren't quite correct.

https://github.com/oskarrough/ember-wordpress/blob/master/tests/dummy/app/router.js

This will allow ember to automatically know the type of model and the two routes won't conflict any longer.

sheriffderek commented 8 years ago

Are you counting on some default assumptions that ember-data uses by using the post_slug underscore style for the dynamic route?

I'm having a hell of a time getting slugs in order and I'm cross-checking this dummy app / ember-observer / and a few others. I'm wondering if there is some under the hood stuff I'm missing. could you in theory use :pageSlug ? http://stackoverflow.com/questions/38134351/dynamic-segments-other-than-id-in-ember-js

oskarrough commented 8 years ago

Yes, if you follow the :modeltype_parameter pattern when you define your routes, Ember will try to find the model by it self.

There were some wrong code in the demo app, as you pointed out. But if you check https://github.com/oskarrough/ember-wordpress/commit/629fa0c3742681e5e862e75995ab6504c319d4a2 or the current state of the demo app routes, you'll hopefully see how it can work. Otherwise let me know!