Skip to content

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

Description

@ramusus

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?

Activity

  1. cwagner22 commented on Nov 22, 2014

    @cwagner22

    same issue

  2. chaddy81 commented on Jan 19, 2015

    @chaddy81

    Any fix or workarounds for this yet?

  3. dbachrach commented on May 22, 2015

    @dbachrach

    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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions