I keep running into an issue with my app. When I start my local rails server and run the chrome ember inspector tool I get a few errors with obviously the fact that it seems to be just rendering a blank page. My index page works however when I use the /#/stories it renders a blank page. Previously it was working so I must've broken some code somewhere, but I can't seem to find the issue. I'm very new to ember, and somewhat new to ruby.
Error one: Uncaught SyntaxError: Unexpected identifier. stories_route.js line: 13
Sample.StoriesRoute = Ember.Route.extend({
model: function() {
this.store.find('story');
return this.store.filter('story', function(story) {
return !story.get('isNew');
});
},
actions: {
"delete": function(story)
story.destroyRecord();
}
}
});
And my second error: Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed (generated stories controller)
code for application.js:
Sample.Router.map(function() {
this.resource('stories', function() {
this.resource('story', { path: ':story_id'}, function() {
this.route('edit');
});
this.route('new');
});
});
code for stories_controller.rb
class StoriesController < ApplicationController
def index
render json: Story.all
end
def show
render json: Story.find(params[:id])
end
def create
sleep 1
render json: Story.create(story)
end
def update
render json: Story.find(params[:id]).tap { |s| s.update_attributes(story) }
end
def destroy
story.find(params[:id]).destroy
head 204
end
private
def story
params[:story].permit(:title, :body)
end
end
Any help would be greatly appreciated. I hope I made the errors unambiguous.