node4good / formage

Bootstraped Admin GUI addon for mongoose, jugglingdb, or just as a form generator
formage.io
MIT License
185 stars 55 forks source link

ReferenceError: model `User` not registered, referred by model `Article` #124

Open ramusus opened 9 years ago

ramusus commented 9 years ago

I'm trying to register default users from the project meanjs.org. But if Article has reference to User server fault with error:

ReferenceError: model `User` not registered, referred by model `Article`

I registered models by this snippet:

    require('formage').init(app, express, require(path.resolve('./app/models')), {
        title: 'Admin',
        root: '/admin',
        default_section: 'main',
        username: 'admin',
        password: 'admin',
        admin_users_gui: true
    });

And put ./app/models/index.js with:

'use strict';
module.exports.user = require('./user.server.model');
module.exports.article = require('./article.server.model');

Changing models order doesn't help. Where I'm wrong?

cwagner22 commented 9 years ago

same issue

chaddy81 commented 9 years ago

Any fix or workarounds for this yet?

dbachrach commented 9 years ago

I just ran into this and the fix is to get the capitalization correct. You registered your mongo models as 'User' and 'Article', but when you exported them for formage in index.js you used lowercase 'user' and 'article'.

You should change it to:

'use strict';
module.exports.User = require('./user.server.model');
module.exports.Article = require('./article.server.model');