Edit: The correct answer is below, you need to iterate over the error objects. I’ve created a JSBin: http://jsbin.com/motuvaye/6/edit
I’m trying to handle server side validation errors with vanilla ember.
My Rails controller:
def create
@story = Story.create(story)
if @story.valid?
render json: @story
else
render json: {errors: @story.errors}, status: 422
end
end
My route:
MyApp.StoriesNewRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('story');
},
actions: {
create: function(story){
var route = this;
story.save().then(function(){
route.transitionTo('stories');
});
}
}});
The errors that come back currently look like this:
{"errors":{"title":["should begin with a capital letter"]}}
What should the errors look like?
How can I insert the title error onto my handlebars page so that I can show the title error next to the title ( not in a general isError block )
Thank you!