0
votes

I am creating one app and getting the following error:

TypeError: Accounts.createUser is not a function

Here is my Code:

    Template.register.events({
    'submit form': function(event){
    event.preventDefault();
    var email = $('[name=email]').val();
    var password = $('[name=password]').val();
        var fname = $('[name=fname]').val();
        var lname = $('[name=lname]').val();

    Accounts.createUser({
        email: email,
        password: password,
            profile: {
            fname: fname,
            lname: lname,
            IsActive: 0
            }

    });
    Router.go('home');
    }
});

I am using the : accounts-password package

I am also using the MONGO_URL (MONGO_URL=mongodb://localhost:27017/MYDB)

I have tried : meteor reset

also recreated the app by : meteor create myapp

I can login thru the already created user, Previously it was not giving any issues and I created one User, but now it is giving this issue, What should I do?

2
show us your .meteor/packages file - Adam Wolski

2 Answers

1
votes

Here is what I was doing wrong :

I was using a collection having a name as Accounts, see below :

OLD CODE

Accounts = new Meteor.Collection('accounts');

Subscriptions :

Meteor.publish('Accounts', function(){
return Accounts.find();
});

and using the Helpers:

Template.account_screen_account_view.helpers({

FetchAccountViewData: function () {
var editid = Router.current().params._id;
return CustomerAccounts.findOne({_id:editid});
}

});

It was conflicting with the following code:

  Accounts.createUser({
    email: email,
    password: password,
        profile: {
        fname: fname,
        lname: lname,
        IsActive: 0
        }

});

NEW CODE (CHANGED)

CustomerAccounts = new Meteor.Collection('customeraccounts');

Meteor.publish('CustomerAccounts', function(){
return CustomerAccounts.find();
});


Template.account_screen_account_view.helpers({

FetchAccountViewData: function () {
var editid = Router.current().params._id;
return CustomerAccounts.findOne({_id:editid});
}

});

Now the issue is resolved. Sometimes we forget to look into these things, I am happy to share my experience as if you use Meteor Accounts, then you need to change the name of your own collections and functions as they can conflict and create these type of issues.

0
votes

Please verify your field names same or not. If those are same try this:

funname:function(event,target){
    email=target.find(".your field class name or # field id").value;

}