Я боролся с тем, чтобы заставить приложение Ember Application работать с Firebase. Я просмотрел все сообщения здесь, в Stackoverflow о подобном вопросе, но я не нашел ответа на свою проблему. Так вот:EmberError: Ничего не обработано действие
Всякий раз, когда я пытаюсь поместить данные в поле ввода и представить их с помощью кнопки я получаю ошибку консоли:
EmberError
code : undefined
description : undefined
fileName : undefined
lineNumber : undefined
message :
"Nothing handled the action 'createBook'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble."
Мою модель:
import DS from 'ember-data';
export default DS.Model.extend({
title: DS.attr('string'),
author: DS.attr('string'),
picture: DS.attr('string'),
buyer: DS.attr('string'),
bought: DS.attr('boolean', { defaultValue: false }),
createdAt: DS.attr('date', { defaultValue() { return new Date(); } })
});
И мой контроллер :
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
createBook: function(){
var newBook = this.store.createRecord('book', {
title: this.get('title'),
author: this.get('author'),
picture: this.get('picture'),
buyer: this.get('buyer'),
bought: this.set(false),
createdAt: new Date().getTime()
});
newBook.save();
//reset values after create
this.setProperties({'title' : '',
'author' : '',
'picture' : '',
'buyer' : ''
});
}
}
});
шаблон:
{{outlet}}
<div style ="margin-left:130px;">
<h1> blabla </h1>
{{input type="text" value=title placeholder="Add Title"}}<br>
{{input type="text" value=author placeholder="Add author"}}<br>
{{input type="text" value=picture placeholder="Add picture"}}<br>
{{input type="text" value=buyer placeholder="buyer"}}<br>
</div>
<button class="btn btn-default" {{action "createBook" }}> Create</button>
{{#each model as |book|}}
<ul>
<li>{{book.title}}</li>
</ul>
{{/each}}
Соединение между Firebase и Ember установлено на 100% правильно. На данный момент правила для firebase установлены на true
для чтения и записи. Единственная проблема заключается в том, что он не отправляет данные в Firebase.
Вы уверены, что это правильный контроллер для этого шаблона? Проверьте имена файлов, лучше опубликуйте их. С каталогом относительно ваших проектов root. – Lux