meteor-collection-helpers
meteor-collection-helpers copied to clipboard
Meteor.users.helpers not defined
Hi,
I'm trying to use this package to link to another document on the users collection. Its throwing an error at the line 'Meteor.users.helpers({....});' It does this on a freshly created meteor project version 1.0.3.2 Any ideas what it could be?
Thanks
Hey @JimHough what's the error message you saw?
Same problem here. I installed latest windows preview release from https://github.com/meteor/meteor/wiki/Preview-of-Meteor-on-Windows
When I start the app - I get this error:
W20150306-15:24:50.920(5.5)? (STDERR)
W20150306-15:24:50.922(5.5)? (STDERR) C:\Users\username\AppData\Local\.meteor\packages\meteor-tool\1.1.0-winr.12\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:245
W20150306-15:24:50.922(5.5)? (STDERR) throw(ex);
W20150306-15:24:50.922(5.5)? (STDERR) ^
W20150306-15:24:50.922(5.5)? (STDERR) TypeError: Object [object Object] has no method 'helpers'
W20150306-15:24:50.922(5.5)? (STDERR) at app\collections\users.js:3:14
W20150306-15:24:50.922(5.5)? (STDERR) at app\collections\users.js:10:3
W20150306-15:24:50.923(5.5)? (STDERR) at D:\code\apps\dummyapp\dummyapp\.meteor\local\build\programs\server\boot.js:222:10
W20150306-15:24:50.923(5.5)? (STDERR) at Array.forEach (native)
W20150306-15:24:50.923(5.5)? (STDERR) at Function._.each._.forEach (C:\Users\username\AppData\Local\.meteor\packages\meteor-tool\1.1.0-winr.12\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20150306-15:24:50.923(5.5)? (STDERR) at D:\code\apps\dummyapp\dummyapp\.meteor\local\build\programs\server\boot.js:117:5
W20150306-15:24:56.408(5.5)? (STDERR)
W20150306-15:24:56.409(5.5)? (STDERR) C:\Users\username\AppData\Local\.meteor\packages\meteor-tool\1.1.0-winr.12\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:245
W20150306-15:24:56.409(5.5)? (STDERR) throw(ex);
W20150306-15:24:56.409(5.5)? (STDERR) ^
W20150306-15:24:56.409(5.5)? (STDERR) TypeError: Object [object Object] has no method 'helpers'
W20150306-15:24:56.409(5.5)? (STDERR) at app\collections\users.js:3:14
W20150306-15:24:56.409(5.5)? (STDERR) at app\collections\users.js:10:3
W20150306-15:24:56.409(5.5)? (STDERR) at D:\code\apps\dummyapp\dummyapp\.meteor\local\build\programs\server\boot.js:222:10
W20150306-15:24:56.410(5.5)? (STDERR) at Array.forEach (native)
W20150306-15:24:56.410(5.5)? (STDERR) at Function._.each._.forEach (C:\Users\username\AppData\Local\.meteor\packages\meteor-tool\1.1.0-winr.12\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20150306-15:24:56.410(5.5)? (STDERR) at D:\code\apps\dummyapp\dummyapp\.meteor\local\build\programs\server\boot.js:117:5
=> Exited with code: 8
W20150306-15:25:01.627(5.5)? (STDERR)
W20150306-15:25:01.627(5.5)? (STDERR) C:\Users\username\AppData\Local\.meteor\packages\meteor-tool\1.1.0-winr.12\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:245
W20150306-15:25:01.628(5.5)? (STDERR) ^
W20150306-15:25:01.628(5.5)? (STDERR) TypeError: Object [object Object] has no method 'helpers'
W20150306-15:25:01.628(5.5)? (STDERR) at app\collections\users.js:3:14
W20150306-15:25:01.629(5.5)? (STDERR) at app\collections\users.js:10:3
W20150306-15:25:01.629(5.5)? (STDERR) at D:\code\apps\dummyapp\dummyapp\.meteor\local\build\programs\server\boot.js:222:10
W20150306-15:25:01.629(5.5)? (STDERR) at Array.forEach (native)
W20150306-15:25:01.629(5.5)? (STDERR) at Function._.each._.forEach (C:\Users\username\AppData\Local\.meteor\packages\meteor-tool\1.1.0-winr.12\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20150306-15:25:01.628(5.5)? (STDERR) throw(ex);
W20150306-15:25:01.630(5.5)? (STDERR) at D:\code\apps\dummyapp\dummyapp\.meteor\local\build\programs\server\boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
I wrote the following code in users.js
Meteor.users.helpers({ some code here });
Does it work okay on other collections?
Actually, I am using the package on users collections only. Let me check.
EDIT: Yes. the package is working on other collections. I think the problem is with users at the moment.
I have the same when updating meteor. Actually had the issue for quite a time. It could have to do with the need to go from Meteor.collection to Mongo.collection but this is just an educated guess.
I wonder if this current bug is windows specific, @JimHough are you running Meteor on windows by any chance?
@dburles using Ubuntu 14.04. Not working on any of my three systems (all Ubuntu 14.04)
I am also running on Ubuntu 14.04. It seems as though the helpers prototype is not applied or is deleted from the users collection.
@dburles Will you be able to work on this in the foreseeable future?
I made the warning go away by doing:
var Users = Meteor.users;
Users.helpers({});
This was quite helpful: https://github.com/ongoworks/meteor-security/issues/5
Can the others confirm that they are also using collection-behaviours?
@JimHough tried this project today on Ubuntu 14.04 and couldn't reproduce your error, are you sure that the issue isn't caused by a package conflict like @Levino ?
Having problems meself with this
@AlexFrazer any further info you may have, such as system etc would be super useful thanks!
@dburles, I am sorry, it seemed this was a result of pub/sub. My solution was to put it in a null publication.
Meteor.publish(null, function () {
return Meteor.users.find({
_id: this.userId
}, {
fields: {
services: false
}
});
}, { is_auto: true });
I am getting another error related to Meteor.users.helpers. While the exception is generated by your code, the error is not caused by your code. I inherited this project and am getting the error Error: [Can't apply helpers to 'users' a transform function already exists!] when I try to implement Meteor.users.helpers for kaoskeya:admin kaoskeya:accounts-autoform-admin Have searched my app and cannot locate a duplicate of Meteor.users.helpers. Any suggestions as to how to fix this problem? Thanks.
meteor list
255kb:meteor-status 1.2.0* Meteor Status automatically alerts u...
3stack:presence 1.0.3 Track who' online on your app, and w...
accounts-base 1.2.0 A user account system
accounts-facebook 1.0.4 Login service for Facebook accounts
accounts-google 1.0.4 Login service for Google accounts
accounts-password 1.1.1 Password support for accounts
alanning:roles 1.2.13 Role-based authorization
aldeed:autoform 4.2.2* Easily create forms with automatic i...
aldeed:collection2 2.3.3 Automatic validation of insert and u...
aldeed:template-extension 3.4.3 Adds template features currently mis...
avatar 0.7.6+ Consolidated user avatar template (t...
base-model 0.1.3+ A model for all other models to inhe...
bootstrap-contextmenu 0.0.1+ A meter package wrapper to https://g...
canvas-roles 0.0.0+
cfs:graphicsmagick 0.0.18 Adds gm to scope with the ability...
circular-menu 0.0.0+
dburles:collection-helpers 1.0.3 Transform your collections with help...
dburles:jquery-tinysort 0.5.5 TinySort, a small and simple jQuery ...
dsyko:meteor-node-csv 0.3.7 node-csv npm packaged for meteor.
email 1.0.6 Send email messages
fds:keycodes 1.0.2 Names for event key codes
force-ssl 1.0.4 Require this application to use HTTPS
fortawesome:fontawesome 4.3.0 Font Awesome (official): 500+ scalab...
hammer:hammer 2.0.4_2 Hammer.js (official) - multi-touch...
html-parser 0.0.0+
html2canvas 0.0.0+
http 1.1.0 Make HTTP calls to remote servers
intercom-local 1.2.4+ Intercom.io basic integration (uses ...
iron:router 1.0.7* Routing specifically designed for Me...
jag:pince 0.0.6* A logger for Meteor inspired by log4...
jquery 1.11.3_2 Manipulate the DOM using CSS sele...
jstree 3.1.0+ Package wrapper for jstree plugin.
kaoskeya:accounts-autoform-admin 0.0.1 Manage users module for kaoskeya:adm...
kaoskeya:admin 0.2.5 Simple autoform based admin that int...
matb33:collection-hooks 0.7.13 Extends Mongo.Collection with befor...
matdutour:outdated-browser 0.1.1 Detects outdated browsers and advise...
meteor-platform 1.2.2 Include a standard set of Meteor pac...
meteorhacks:cluster 1.6.4* Clustering solution for Meteor with ...
meteorhacks:kadira 2.20.3* Performance Monitoring for Meteor
meteorhacks:kadira-profiler 1.1.0* CPU Profiler for Kadira
meteorhacks:npm 1.3.0 Use npm modules with your Meteor App
meteorhacks:zones 1.4.0* Zone.Js integration for meteor
mirageglobe:html5shivcdn 1.2.3 Latest version html5shiv loaded via ...
mizzao:jquery-ui 1.11.2 Simple lightweight pull-in for jQue...
momentjs:moment 2.10.3 Moment.js (official): parse, valida...
mrt:cron 0.0.1 Simple meteor.cron
npm-container 1.0.0+ Contains all your npm dependencies
ongoworks:security 1.1.0* Logical security for client-originat...
pascoual:pdfkit 1.0.5 PDFKit, the PDF generation library
pauli:accounts-linkedin 1.1.2 Accounts service for LinkedIn accounts
pfafman:multer 0.1.0 Add Multer to meteor
plotter 0.0.0+
redactor 10.0.5+ Redactor WYSIWYG html editor.
reywood:iron-router-ga 0.6.0 Google analytics (universal edition)...
s3-server 0.0.0+ Upload files to S3. Allows use of Kn...
sacha:spin 2.0.4* Simple spinner package for Meteor
selection-box 0.0.0+
selectionchange-polyfill 0.0.0+
sergeyt:livequery 1.3.7 Live Query utilizes the power of jQu...
server-time 0.1.0+ Package to compensate for client/ser...
service-configuration 1.0.4 Manage the configuration for third-p...
socialize:messaging 0.2.1+ A social messaging package LOCAL
tmeasday:html5-history-api 4.1.2 HTML5 History API expansion for brow...
twbs:bootstrap 3.3.4* The most popular front-end framework...
underscore 1.0.3 Collection of small helpers: _.map, ...
user-model 0.1.2+ A social user package
useraccounts:bootstrap 1.9.1* Accounts Templates styled for Twitte...
uzumaxy:prevent-backspace 0.0.1 Prevents the backspace from navigati...
voidale:better-emails 0.0.1+ Send Better Emails
voidale:bootstrap-alerts 0.3.5 Bootstrap styled alerts with halflings
voidale:bootstrap-dynamic-modal 0.0.1+ Simple shortcut of bootstrap 3 modals.
voidale:meteor-notification 0.0.2+ Adds notification functionality
voidale:minimap 0.0.1+ Wrapper for mgMiniMap Jquery minimap...
voidale:nano-scroller 0.8.6+ A wrapper for nano Custom Scrollbar.
voidale:offcanvas-chat 0.0.1+ Simple off canvas chat
voidale:stripe-subscriptions 0.0.1+ Complete package for Stripe Subscipt...
webshot 0.0.0+ Webshot - NPM Screenshot Library usi...
zimme:iron-router-active 1.0.4* Active route/path template helpers f...
@dougserfass it appears as though another package has added a transform function to the Meteor.users collection.
as you can see from meteor list, i inherited a lot of added packages in this project i am working with kaoskeya to try to identify the package with the transform function do you know of any easy way to determine which package contains the transform function?
I am getting the same error
W20150729-18:44:26.862(7)? (STDERR) /Users/username/.meteor/packages/meteor-tool/.1.1.3.hn2ytd++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:245
W20150729-18:44:26.862(7)? (STDERR) throw(ex);
W20150729-18:44:26.862(7)? (STDERR) ^
W20150729-18:44:26.867(7)? (STDERR) TypeError: Object [object Object] has no method 'helpers'
W20150729-18:44:26.867(7)? (STDERR) at RouteController.extend.layoutTemplate (packages/me:post/collections/news.js:2:1)
W20150729-18:44:26.867(7)? (STDERR) at /Users/username/Documents/lab/project1/myapp/meteor/.meteor/local/build/programs/server/packages/me_post.js:161:4
W20150729-18:44:26.867(7)? (STDERR) at /Users/username/Documents/lab/project1/myapp/meteor/.meteor/local/build/programs/server/packages/me_post.js:222:3
W20150729-18:44:26.867(7)? (STDERR) at /Users/username/Documents/lab/project1/myapp/meteor/.meteor/local/build/programs/server/boot.js:222:10
W20150729-18:44:26.867(7)? (STDERR) at Array.forEach (native)
W20150729-18:44:26.867(7)? (STDERR) at Function._.each._.forEach (/Users/username/.meteor/packages/meteor-tool/.1.1.3.hn2ytd++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150729-18:44:26.867(7)? (STDERR) at /Users/username/Documents/lab/project1/myapp/meteor/.meteor/local/build/programs/server/boot.js:117:5
Here is my usage, even if I comment out my implementation and leave only the News.helper I still get an error.
News = new Mongo.Collection('news');
News.helpers({
imageUrl: function() {
var image = Images.find(this.image_id);
return image.url({store:'images'});
},
thumbnailUrl: function() {
var image = Images.find(this.image_id);
return image.url({store:'thumbs'});
}
});
Here is my package list, I saw in another issue that collectionFS might not work with this package?
accounts-password 1.1.1 Password support for accounts
accounts-ui 1.1.5 Simple templates to add login widgets to...
aldeed:autoform 5.3.2 Easily create forms with automatic inser...
aldeed:collection2 2.3.3 Automatic validation of insert and updat...
cfs:ejson-file 0.1.4 CollectionFS, FS.File as EJSON type
cfs:filesystem 0.1.2 Filesystem storage adapter for CollectionFS
cfs:graphicsmagick 0.0.18 Adds `gm` to scope with the ability to ...
cfs:standard-packages 0.5.9 Filesystem for Meteor, collectionFS
dburles:collection-helpers 0.1.6* Collection helpers
fortawesome:fontawesome 4.3.0 Font Awesome (official): 500+ scalable v...
iron:router 1.0.9 Routing specifically designed for Meteor
jquery 1.11.3_2 Manipulate the DOM using CSS selectors
less 1.0.14 The dynamic stylesheet language
meteor-platform 1.2.2 Include a standard set of Meteor package...
sacha:spin 2.3.1 Simple spinner package for Meteor
underscore 1.0.3 Collection of small helpers: _.map, _.ea...
zcurtis:uikit 2.21.2 UIKit repackaged for Meteor (from fork)
Hey @harinsa somehow your project is using a very old version of collection-helpers.
@dburles whoops, sorry about that, did not specify the version and somehow meteor gave me that version. Change to @1.0.3 and it works now.
Hi, i am having the same problem :(
we can't attach helpers to Meteor.users
@crapthings Please elaborate, give some references. Thanks.
Meteor.users.helpers
organization: ->
Organizations.findOne @organizationId
ypeError: Object [object Object] has no method 'helpers' W20151005-23:47:17.861(8)? (STDERR) at collections/users.coffee:1:14 W20151005-23:47:17.861(8)? (STDERR) at collections/users.coffee:1:1 W20151005-23:47:17.862(8)? (STDERR) at /Volumes/Data/dev/nexushubs/lawflow/mobile1/.meteor/local/build/programs/server/boot.js:242:10 W20151005-23:47:17.862(8)? (STDERR) at Array.forEach (native) W20151005-23:47:17.862(8)? (STDERR) at Function..each..forEach (/Users/monsterstep/.meteor/packages/meteor-tool/.1.1.9.1mnd3gj++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11) W20151005-23:47:17.862(8)? (STDERR) at /Volumes/Data/dev/nexushubs/lawflow/mobile1/.meteor/local/build/programs/server/boot.js:137:5
@crapthings This is not how this works...
FYI - this happens when you add any package which applies a _transform on the Meteor.users collection... for example it can be replicated very easily by adding both this package and https://github.com/copleykj/socialize-user-model/
$ grep -r '_transform' .meteor/local/build/programs/server/packages/
Hey @zeroasterisk are you applying helpers to Meteor.users or Users?
Though from glancing at the source code, it's unlikely that it wouldn't conflict with collection-helpers
Well. I'm having the same kind of error, but not exactly with the same setup.
I can't use collection-helpers inside any packages. I have some local packages, one of them (app-core) declares a bunch of collections and helpers and export them for use by other local packages and the main app.
I'm getting `Object [object Object] has no method 'helpers'"
I tried api.use('dburles:collection-helpers') on the same package as the collections, on another package required by the app-core package and on the main app, but nothing works.
The only way to make it work is putting my collections.js in the main app and requiring dburles:collection-helpers from the main app too.