Resource Route Empty Screen


#1

Following example

this.route('app', {path: ''}, function() {
    this.resource('test');
});

<script type="text/x-handlebars" data-template-name="app/test">
    test
</script>

<script type="text/x-handlebars" data-template-name="app">
    [html wrapper...]
    {{outlet}}
</script>

I would like to have a resource route in order to use my fixture data. But all I get is my html wrapper when I call the test route in my browser… When I switch back to a “normal” route my test template (output ‘test’) is correctly rendered. What am I doing wrong?


#2

this.route cannot have anything nested within… You can only nest within a resource, so:

this.resource('app', {path: ''}, function() {
    this.resource('test');
});

But then you are saying that app is the index? so don’t nest at all, just do:

this.resource('test');

and then define a template for index.


#3

Thanks for the good advice! But unfortunately, it doesn’t work either :frowning:

And for the nesting/not nesting thing: I simplified my example, i need the top-level ‘app’ for authentication later


#4

I think resources always work unnested, and you have to specify the nesting manually. Routes nest.

If you really need ‘test’ to be a resource and not a route, I think you should be able to use something like (untested):

this.resource('app', {path: ''}, function() {
    this.resource('app.test');
});

#5

Thanks, but that wouldn’t make any sense :smiley:

Why should I say that test belongs to app, if it is hierachically already specified?


#6

From what I’ve understood, the hierarchical nesting determines which routes get called, while this.resource/this.route determines their naming structure.

I can’t say I find it all that logical, but they’re not the same thing.


#7

@bbc so what happens exactly? No data, an error? Would be nice if you could put together a jsbin (emberjs.jsbin.com)


#8

Great idea! But how can i change the url which is shown in the output of jsbin? By default, it goes into app.index :slight_smile: