I am learning ember and rails from this tutorial https://dockyard.com/blog/2014/05/09/building-an-ember-app-with-rails-part-3
I understand this is a pretty old tutorial and some code does not apply anymore. I am able to fix most of the error during learning process. However, there is one error I have no idea how to fix.
I have this piece of code:
import DS from 'ember-data';
export default DS.ActiveModelAdapter.extend({
namespace: 'api'
});
And I got this error:
Cannot read property 'extend' of undefined@ 187 ms
Expected:
true
Result:
false
Source:
TypeError: Cannot read property 'extend' of undefined
at Module.callback (http://localhost:4200/assets/popular-media-app.js:11:59)
at Module.exports (http://localhost:4200/assets/vendor.js:111:32)
at requireModule (http://localhost:4200/assets/vendor.js:32:18)
at Class._extractDefaultExport (http://localhost:4200/assets/vendor.js:70638:20)
at Class.resolveOther (http://localhost:4200/assets/vendor.js:70359:32)
at Class.superWrapper [as resolveOther] (http://localhost:4200/assets/vendor.js:56118:22)
at Class.resolve (http://localhost:4200/assets/vendor.js:23536:35)
at resolve (http://localhost:4200/assets/vendor.js:21501:36)
at Registry.resolve (http://localhost:4200/assets/vendor.js:21189:21)
at Registry.resolve (http://localhost:4200/assets/vendor.js:21193:55)
After tons of testing, I am sure the problem is cause by ActiveModelAdapter. I went through the documents for this class. It seems fine. I really have no idea why this is an error. Could someone help me with this?
I understand you may not be able to figure out what's wrong with the code I provide, but I really don't know what other code do you need. If you need additional code, please let me know.
I have never worked with the ActiveModelAdapter
but it is not a default adapter for ember-data.
You may need to install it using:
ember install active-model-adapter
and I believe you want to import it from the active-model-adapter
instead of DS
:
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
namespace: 'api'
});
More details at: https://github.com/ember-data/active-model-adapter