I'm building an Ember application using ember-data and rails as an API. I'm trying to call a find method on a BusinessNotifications model from the application.js file. When making the initial call I get the "has no method 'find'" error.
My application.js file:
//= require jquery
//= require jquery_ujs
// require jquery.ui.all
//= require handlebars
//= require ember
//= require ember-data
//= require ember-auth
//= require_self
//= require auth
//= require company_backend
//= require ./wepay
//= require_tree .
//= stub polyfills/aight.js
//= stub polyfills/aight.d3.js
//= stub polyfills/mediaqueries.js
//= stub polyfills/pointerevents.js
//= stub polyfills/svg.js
window.CompanyBackend = Em.Application.create({
ready: function() {
var BusinessNotifications = CompanyBackend.BusinessNotification.find();
setInterval(function() {
BusinessNotifications.reload();
}, 2000);
},
});
My Model:
CompanyBackend.BusinessNotification = DS.Model.extend({
notification: DS.attr('string'),
timeSeen: DS.attr('integer'),
active: DS.attr('boolean'),
type: DS.attr('string'),
});
My Serializer:
class BusinessNotificationSerializer < BaseSerializer
attributes :id, :business_id, :notification, :time_seen, :active, :type
end
My Route:
CompanyBackend.BusinessNotificationRoute = Em.Route.extend({
model: function() {
return CompanyBackend.BusinessNotification.find();
},
});
my router.js:
this.resource('business_notification', { path: '/' });
I have the controller and the route set up on the rails end, but those should be irrelevant or I would be getting some sort of rails error in the console.
Thanks for the help!