Namespaced Resources Require Specifying param #36

seanabrahams opened this Issue Sep 15, 2011 · 4 comments

3 participants



app.resource('admin/users', require('./app/resources/admin/users'), { id: 'user' });

Doesn't work...

app.resource('admin/users', require('./app/resources/admin/users'));

In the "Doesn't work..." example the param will be ":admin/user" instead of ":user".


Sean, oh my, this took me forever to figure it out! I spent numerous hours trying. This fix makes sense and it works on my plate


// URLS:
//    Index page: http://localhost:3000/api/
//    Service Index page: http://localhost:3000/api/foo/
//    Service Resource page: http://localhost:3000/api/foo/something

var express = require('express')
  , resource = require('../')
  , app = express.createServer();

var api = {
  index: function(req, res){
    res.send('api index');

var foo = {
  index: function(req, res){
    res.send('foo index');
  show: function(req, res) {
    res.send('bar all');

app.resource('api', api);
app.resource('api/foo', foo, { id: 'foo' });


I guess this is as designed, I will write up some docs so others wont come to the same issue


Actually, would be nice if the default was named "id"

@tj tj closed this in 60746f6 Oct 15, 2011

Thanks, works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment