Change routes from an older version

Hi Guys,

we are trying to upgrade our packages within a project and we encoutered an issue with our routes. there is still some resourses used there. example :

Summary
  this.route('objects', function () {
    this.route('search', { path: '/' }, function () {
      this.resource('objects.items', { path: '/:search_id' }, function () {
        this.resource('objects.item', { path: '/item/:item_id'}, function () {
          this.route('general', { path: '/' });
          this.route('tab', { path: '/tab/:tab' });
          this.route('relations');
          this.route('diagram');
          this.route('comments');
          this.route('sources');
          this.route('views');
        });
      });
    });
  });

is there a way we can migrate these routes without doing too much refactoring? please note that the first resourse (this.resource(‘objects.items’, { path: ‘/:search_id’ }), is working like an optional segment. this is the most important thing which we are not managing to migrate accordinly. and to maintain it’s nested routes without duplicating the nested ones. any help is appreaciated.

If I recall correctly, you can replace:

this.resource('objects.items', { path: '/:search_id' }, function () {

with

this.route('object.items', { path: '/:search_id', resetNamespace: true }, function() {

And everything else should continue working as before.

[EDITED to fix code typo so future readers aren’t burned by it.]

Tried that, but not entirely. now for example i get error messages like “There is no route named objects.item.comments”, but also alot of " Assertion Failed: You attempted to define a {{link-to "objects.item"}} but did not pass the parameters required for generating its dynamic segments. There is no route named objects.item".

I had a typo above, it should say “resetNamespace”.

yes, for some reason didn’t worked for me. but now it works. it was something else, but the console pointed to the route, and i thought it’s not working. so thanks!