Ruby on rails 为什么我在一个基本Rails+;余烬应用程序?
我正在尝试使用Ember+Rails制作一个简单的CRUD应用程序,在尝试转到Ruby on rails 为什么我在一个基本Rails+;余烬应用程序?,ruby-on-rails,ember.js,Ruby On Rails,Ember.js,我正在尝试使用Ember+Rails制作一个简单的CRUD应用程序,在尝试转到/workouts路线时,我遇到了以下错误 Error while loading route: TypeError {} ember.js?body=1:415 Uncaught TypeError: Object function () { if (!wasApplied) { Class.proto(); // prepare prototype... } o_definePr
/workouts
路线时,我遇到了以下错误
Error while loading route: TypeError {} ember.js?body=1:415
Uncaught TypeError: Object function () {
if (!wasApplied) {
Class.proto(); // prepare prototype...
}
o_defineProperty(this, GUID_KEY, undefinedDescriptor);
o_defineProperty(this, '_super', undefinedDescriptor);
var m = meta(this), proto = m.proto;
m.proto = this;
if (initMixins) {
// capture locally so we can clear the closed over variable
var mixins = initMixins;
initMixins = null;
this.reopen.apply(this, mixins);
}
if (initProperties) {
// capture locally so we can clear the closed over variable
var props = initProperties;
initProperties = null;
var concatenatedProperties = this.concatenatedProperties;
for (var i = 0, l = props.length; i < l; i++) {
var properties = props[i];
Ember.assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof Ember.Mixin));
for (var keyName in properties) {
if (!properties.hasOwnProperty(keyName)) { continue; }
var value = properties[keyName],
IS_BINDING = Ember.IS_BINDING;
if (IS_BINDING.test(keyName)) {
var bindings = m.bindings;
if (!bindings) {
bindings = m.bindings = {};
} else if (!m.hasOwnProperty('bindings')) {
bindings = m.bindings = o_create(m.bindings);
}
bindings[keyName] = value;
}
var desc = m.descs[keyName];
Ember.assert("Ember.Object.create no longer supports defining computed properties.", !(value instanceof Ember.ComputedProperty));
Ember.assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));
Ember.assert("`actions` must be provided at extend time, not at create time, when Ember.ActionHandler is used (i.e. views, controllers & routes).", !((keyName === 'actions') && Ember.ActionHandler.detect(this)));
if (concatenatedProperties && indexOf(concatenatedProperties, keyName) >= 0) {
var baseValue = this[keyName];
if (baseValue) {
if ('function' === typeof baseValue.concat) {
value = baseValue.concat(value);
} else {
value = Ember.makeArray(baseValue).concat(value);
}
} else {
value = Ember.makeArray(value);
}
}
if (desc) {
desc.set(this, keyName, value);
} else {
if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {
this.setUnknownProperty(keyName, value);
} else if (MANDATORY_SETTER) {
Ember.defineProperty(this, keyName, null, value); // setup mandatory setter
} else {
this[keyName] = value;
}
}
}
}
}
finishPartial(this, m);
this.init.apply(this, arguments);
m.proto = proto;
finishChains(this);
sendEvent(this, "init");
} has no method 'find'
这实际上并没有返回任何内容。如何从那里调试
如果我把它换成这个
EmberWorkouts.WorkoutsRoute = Ember.Route.extend
model: -> [{title: 'hi'}, {title: 'damn'}]
视图实际上呈现内容
如何使模型正确地从Rails收集?当前版本中,余烬数据的界面发生了一些变化:
store.js
文件。余烬数据将使用REST适配器自动为您设置数据存储(除非您另有说明)model:->@store.find('workout')
json.scans do
json.array! @scans do |scan|
json.id scan.id # This prop has to be there
json.name scan.name
end
end
余烬模型:
EmberApp.Scan = DS.Model.extend(
// Don't include the id prop here
name: DS.attr("string")
)
你的错误信息是什么?行号?那是我的错误信息。我的
EmberWorkouts.WorkoutsRoute=Ember.Route.extend(模型:->EmberWorkouts.Workout.find())
被破坏。这实际上没有任何作用。我如何从那里调试?我得到以下信息:断言失败:你必须在传递给push的哈希中包含一个id
-谢谢。好提示。我会尝试解决它…我仍然无法解决。更新了repo以反映我的障碍。有什么想法吗?@dylan解决方案是什么?说你可能有找到一个解决方案而不发布它很可能是你在这个网站上能做的最烦人的事情。不确定是否有其他人拥有你必须在一个哈希中包含一个“id”来推送问题,但对我来说,修复方法是通过序列化程序的JSON响应传递一个id。此外,余烬模型不能有id属性spe西菲德。
EmberApp.Scan = DS.Model.extend(
// Don't include the id prop here
name: DS.attr("string")
)