Yogiben admin with meteor 1.3? (global var issue)

HI all,

Can we use https://github.com/yogiben/meteor-admin with meteor 1.3? It relies on global vars, now and just importing the collection did not work.

Error: Customers is not in the [object global]
    at lookup (meteor://💻app/packages/yogiben_admin/lib/both/utils.coffee:22:14)
    at adminCollectionObject (meteor://💻app/packages/yogiben_admin/lib/both/utils.coffee:5:3)
    at meteor://💻app/packages/yogiben_admin/lib/both/utils.coffee:36:13
    at Function._.each._.forEach (meteor://💻app/packages/underscore/underscore.js:113:1)
    at adminCreateTables (meteor://💻app/packages/yogiben_admin/lib/both/utils.coffee:36:13)
    at __coffeescriptShare (meteor://💻app/packages/yogiben_admin/lib/both/utils.coffee:36:13)
    at C:\Users\mbj\Documents\GitHub\QRSMeteor\.meteor\local\build\programs\server\boot.js:304:5
Exited with code: 8
Your application is crashing. Waiting for file change.

thank you

Unfortunately this doesn’t seem to be documented but you can use collectionObject key to specify collection by variable and not global name, e.g:

import Posts from '/imports/api/posts';

AdminConfig = {
  collections: {
    Posts: {
      collectionObject: Posts,
      // ...
    } 
  }
};
2 Likes

You can just make your collections global somewhere - I use a file called admin.js in lib where I also configure the admin, so that it’s all in the same place.

import Customers as _Customers from '../collections/customers' // or whatever
Customers = _Customers // no var, let, const, etc.
1 Like

Make sure the file where Customers is defined is imported on the server.

server/main.js

import '../imports/api/customers.js';

I stopped using it, I got the situation that somehow my subscriptions where not active for all pages inside yogiben… sometimes I saw my users, and next 0… (using mongol I check this)

I know this thread is old , but in case might help someone else who has this issue.

  1. Create app_root_directory/lib/admin_config.js
  2. Edit the above file with entries like :
    import { Purchased } from ‘/imports/api/models.js’; ( import your collection names)
    import { FlowerBatchList } from ‘/imports/api/models.js’;

AdminConfig = {
adminEmails: [‘tomtom@foo.com’],
collections:
{
FlowerBatchList: {collectionObject: FlowerBatchList},
Purchased: {collectionObject: Purchased}
}
}

  1. make sure the user name listed in this config file has a role admin attached to it in your User collection record.
  2. go to localhost:3000/admin , you should see the admin panel .
  3. if you do see the collections but cant edit them , make sure you have the collection schema is all defined in the above config file.

NOTE: you do not need to add users collection to the config file above, it will pick it up automatically.