1602/railway-routes — Issue #2: Issue with invalid controller actions
Author: cayasso
Created: 2011-12-24 05:36:55+00:00
State: open

Hey @1602 I noticed an issue wen routing invalid actions

If I do http://localhost:300/accounts the action of the accounts controller defaults to index, if I do http://localhost:300/accounts/index this also default to index but if I do http://localhost/accounts/invalid-action I get defaulted to the show action(which I think is weird), is this intentional or it is a bug?.

Any ideas?

Thank you!

JB

This is my test handler.

module.exports = function (app) {
var map = new routing.Map(app, handler);
map.resources('accounts');
};

function handler(ns, controller, action) {
try {
var ctlFile = './controllers/' + ns + controller + '_controller';
var responseHandler = {
index: function (req, res) {
res.send('IN INDEX');
},

show: function (req, res) {
res.send('IN SHOW');
},

new: function (req, res) {
res.send('IN NEW');
},

edit: function (req, res) {
res.sed('IN EDIT');
}

}[action];
} catch(e) {}
return responseHandler || function (req, res) {
res.send('Handler not found for ' + ns + controller + '#' + action);
};
}