I'm attempting to build a github issue tracker with ember and ember data. The github API is accessed via a node server (and works fine), but I'm having issues trying to use ember's dynamic segments and I'm not sure of the best way to structure my routes & models.
How should I structure my routes and models if I want the url to be /user/repo/issue
?
I've tried all different combinations of dynamic segments and resources/routes...
this.resource('user', {path: ':user'}, function(){
this.resource('repo', {path: ':repo'}, function(){
this.resource('issue', {path: ':issue_id'});
});
}); // 1
this.resource('repo', {path: ':userAndRepo'}, function(){
this.resource('issue', {path: ':issue_id'});
}); // 2
this.resource('repo', {path: ':userAndRepo'});
this.resource('issue', {path: ':userAndRepo/:issue_id'}); //3
But I can't seem to get it working smoothly. I'm tearing my beard out trying to understand it.
The closest I got was having a combined segment for :userAndRepo
, but for any link-to's I had in my issues template, I had to explicitly set that model on the IssuesController
so that my link-to was {{#link-to 'issues' userAndRepo issue}}
Also, my API was getting hit every time I moved from the child issue
route back into the parent repo
route.
Any ideas or suggestions would be greatly appreciated. Apologies if I haven't explained myself very well.