Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router matching multiple routes to controllers #640

Open
lucaswxp opened this issue Sep 3, 2014 · 1 comment
Open

Router matching multiple routes to controllers #640

lucaswxp opened this issue Sep 3, 2014 · 1 comment

Comments

@lucaswxp
Copy link

lucaswxp commented Sep 3, 2014

I have the following routes defined:

exports.routes = function (map) {
    map.all('admin/:controller/:action');
    map.all('admin/:controller/:action/:id');
    map.all(':controller/:action');
    map.all(':controller/:action/:id');
};

When I visit /admin/mycontroller/index, I see in my console that compound is trying to access both:

Params: {"controller":"mycontroller","action":"index"} // this is correct
Params: {"controller":"admin","action":"mycontroller","id":"index"}

But I was expecting only the first to be routed. Is this a bug? Yes, both routes are valid, but only one is supposed to be executed, not every matching route.

@alexbaumgertner
Copy link

Looks like you defined your routers incorrect.

Maybe you should use namespace, here is an example:

map.namespace('admin', function (admin) {
        admin.resources('posts', {middleware: basic_auth, except: ['show']}, function (post) {
            post.resources('comments');
            post.get('likes', 'posts#likes')
        });
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants