No route matches error

Hi,

I am trying to create a custom route and keep getting this error -

Routing Error
## No route matches [GET] "/test"

This is on a local development setup

I have added the follow to jsapp/app/routes/app-route-map.js

this.route("test");

And created the following file app/assets/javascripts/discourse/app/routes/test.js


import DiscourseRoute from "discourse/routes/discourse";
import { ajax } from 'discourse/lib/ajax';

export default Ember.Route.extend({

  model() {
    return ajax('/test/1.json');
  },
});

I have tried killing my tmp directory and restarting the services to be on the safe side.

Thanks for the help.

Have you also added the route to the Rails router?

Yes the rails part is working correctly and returning the json

I suspect it is caching of some sort. Earlier yesterday, I added a new route /testroute and that is still working. Even if I remove it, save the file and try again.

After much debugging, I think I just realised @Falco your suggestion. I thought I only had to define the rails route for the json I was returning. I didn’t realise the rails route has to follow the same name convention as the ember app.

1 Like