lundi 27 juin 2016

Controller not recognizing Ember Validations mixin

I am creating a sign up form with ember-validations and EmberFire. My server starts up fine, but my console displays this error:

Uncaught Error: Could not find module `app/mixins/validations/signup` imported from `processapp/controllers/signup`

Here is the code for my signup validation mixin:

import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Mixin.create(EmberValidations, {
  validations: {
    "model.firstName": {
      presence: true
    },
    "model.lastName": {
      presence: true
    },
    "model.email": {
        format: { with: /^.+@.+\..+$/, message: 'Please enter a valid email address.' }
    },
    "model.password": {
        length: {minimum: 6, maximum: 30},
        presence: true,
        confirmation: true
    }
  },
});

Here is the code for my signup controller:

import Ember from 'ember';
import SignupValidations from 'app/mixins/validations/signup';

export default Ember.Controller.extend(SignupValidations, {
actions: {
    createUser(){
      //...
      this.validate().then(()=>{
        var newUser = this.store.createRecord('user', {
            firstName: this.get('firstName'),
            lastName: this.get('lastName'),
            email: this.get('email'),
            password: this.get('password')
        });
        newUser.save().then(()=>{
          this.transitionToRoute('user', newUser);
        });
      }).catch(()=>{
        console.log(this.get("errors"));
      });
    }
  }
});

The file structure seems to match the structure included in the import SignupValidations line in my controller so I am a bit confused as to why I am getting this error. Any ideas?




Aucun commentaire:

Enregistrer un commentaire