I use ember-data and I need to insert dependency into data adapter of store. Here is simplified code:
window.App = Ember.Application.create({
ready: function() {
this.register('database:current', this.Database);
// this works fine, this.get('database') inside routes works ok
this.inject('route', 'database', 'database:current');
// but this does not work
this.inject(App.SqliteAdapter, 'database', 'database:current');
// also tried this:
// this.inject('dataAdapter', 'database', 'database:current');
}
});
App.Store = DS.Store.extend({
revision: 13,
adapter: App.SqliteAdapter
});
App.SqliteAdapter = DS.Adapter.extend({
find: function(store, type, id) {
var db = this.get('database');
console.log(db); // this is undefined
}
});
App.Database = Ember.Object.extend({});
Why doesn't this code work?
Versions:
DEBUG: Ember : 1.1.2
DEBUG: Ember Data : 1.0.0-beta.3
DEBUG: Handlebars : 1.0.0
DEBUG: jQuery : 2.0.3