Ember CLI Simple Auth RouteMixins无效

时间:2015-08-11 05:36:15

标签: ember-cli ember-simple-auth

会话正在运行,没有显示任何错误,但没有一个routeMixins正在运行......我似乎有一些类似的问题和他们的解决方案,但不知何故他们没有解决我的错误(或者我误解了他们的实现。这是我目前的应用程序路由器:

import Ember from 'ember';
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend
({
    ApplicationRouteMixin,
    model: function()
    {
        return Ember.Object.create
        ({
            genres: this.store.findAll('genre'),
            factTypes: this.store.findAll('factType'),
            categories: this.store.findAll('category')
        });
    },
    setupController: function(controller, models)
    {
        this._super(controller, models);
    }
});

我也尝试了以下内容但没有取得任何成功:

beforeModel: function(transition, queryParams)
{
    this._super(transition, queryParams);
},

model: function(transition, queryParams)
{
    this._super(transition, queryParams);
    return Ember.Object.create
    ({
        genres: this.store.findAll('genre'),
        factTypes: this.store.findAll('factType'),
        categories: this.store.findAll('category')
    });
}

我在我的应用程序中使用的一些routeMixins:

User.edit

import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin);

登录路线

import Ember from 'ember';
import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin';

export default Ember.Route.extend
({
    UnauthenticatedRouteMixin,
    setupController: function(controller)
    {
        controller.set('errorMessage', null);
    }
});

1 个答案:

答案 0 :(得分:0)

我再次错过了详细信息...此特定问题的答案是将RouteMixins移至导出默认开始括号之前,如下所示:

申请路线

import Ember from 'ember';
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';

export default Ember.Route.extend
(ApplicationRouteMixin, {
    model: function()
    {
        return Ember.Object.create
        ({
            genres: this.store.findAll('genre'),
            factTypes: this.store.findAll('factType'),
            categories: this.store.findAll('category')
        });
    }
});

登录路线

import Ember from 'ember';
import UnauthenticatedRouteMixin from 'simple-auth/mixins/unauthenticated-route-mixin';

export default Ember.Route.extend
(UnauthenticatedRouteMixin,{
    setupController: function(controller)
    {
        controller.set('errorMessage', null);
    }
});

我应该删除这个问题,但你永远不知道其他人是否也犯了同样的错误并且很难检测到它......你可以看到文档here