我有一个包含服务器表的 ember-rails 应用程序,以及到每个单独服务器的链接。
这是主servers.handlebars
文件:
<table id="box-table-a">
<thead>
<th>Name</th>
<th>Operating System</th>
<th>Build Stage</th>
</thead>
<tbody>
{{#each server in controller}}
<tr>
<td>
{{#link-to 'server' server}}
{{server.name}}
{{/link-to}}
</td>
<td>{{server.operating_system}}</td>
<td>{{server.build_stage}}</td>
</tr>
{{/each}}
</tbody>
</table>
{{outlet}}
正如预期的那样,它创建了适当的表。当悬停在服务器名称上时,我将在浏览器的左下角收到 url: #/servers/1
,#/servers/2
等
但是,当我单击指向单个服务器的链接时,不会呈现服务器模板。这是我的server.handlebars
文件:
<div>
<h2> {{name}} </h2>
<h2> {{operating_system}} </h2>
<h2> {{build_stage}} </h2>
</div>
以下是我server.js.coffee
位于 javascripts/models 文件夹中的文件:
Warthog.Server = DS.Model.extend
name: DS.attr('string')
operating_system: DS.attr('string')
build_stage: DS.attr('string')
我的serversRoute.js.coffee
文件:
Warthog.ServersRoute = Ember.Route.extend
model: -> @store.find('server')
我的serverRoutes.js.coffee
文件:
Warthog.ServerRoute = Ember.Route.extend
model: (params) ->
@store.find('server', params.server_id)
最后是router.js.coffee
文件
Warthog.Router.map ->
@resource "servers", ->
@resource "server", path: "/:server_id", ->
@route "edit"
@route "create"
请注意,Chrome 中的 ember 工具箱没有显示任何路由,并且只有在尝试导航到单个服务器时才会在控制台中引发错误。下面是错误。
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery.js?body=1:5387
Ember Debugger Active VM3178:391
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on <Ember.Route:ember430>)
at Object.triggerEvent (http://testdomain.warthog.dev/assets/ember.js?body=1:30519:13)
at trigger (http://testdomain.warthog.dev/assets/ember.js?body=1:29641:16)
at handlerEnteredOrUpdated (http://testdomain.warthog.dev/assets/ember.js?body=1:29537:11)
at http://testdomain.warthog.dev/assets/ember.js?body=1:29512:9
at eachHandler (http://testdomain.warthog.dev/assets/ember.js?body=1:29559:9)
at setupContexts (http://testdomain.warthog.dev/assets/ember.js?body=1:29511:7)
at finalizeTransition (http://testdomain.warthog.dev/assets/ember.js?body=1:29835:7)
at transitionSuccess (http://testdomain.warthog.dev/assets/ember.js?body=1:29732:13)
at invokeCallback (http://testdomain.warthog.dev/assets/ember.js?body=1:8055:19) ember.js?body=1:394
Error while loading route: TypeError {} ember.js?body=1:394
Uncaught TypeError: Object function () {
var Class = makeCtor(), proto;
Class.ClassMixin = Mixin.create(this.ClassMixin);
Class.PrototypeMixin = Mixin.create(this.PrototypeMixin);
Class.ClassMixin.ownerConstructor = Class;
Class.PrototypeMixin.ownerConstructor = Class;
reopen.apply(Class.PrototypeMixin, arguments);
Class.superclass = this;
Class.__super__ = this.prototype;
proto = Class.prototype = o_create(this.prototype);
proto.constructor = Class;
generateGuid(proto, 'ember');
meta(proto).proto = proto; // this will disable observers on prototype
Class.ClassMixin.apply(Class);
return Class;
} has no method 'create'