-
-
Save dustinbrownman/5b7f2d477503d8b8ec30769ea76da5b9 to your computer and use it in GitHub Desktop.
AMS errors - http://git.io/vCQxw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import ActiveModelAdapter from 'active-model-adapter'; | |
| import DS from 'ember-data'; | |
| const ActiveModelAdapter = DS.ActiveModelAdapter; | |
| export default ActiveModelAdapter.extend(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Controller.extend({ | |
| conditionErrors: () => { | |
| return "something" | |
| }, | |
| actions: { | |
| updateUser: function(user) { | |
| user.save().then(null, res => { | |
| const conditionErrorMessages = user.get('errors').errorsFor('conditions'); | |
| user.set('conditionErrors', conditionErrorMessages); | |
| }); | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| model: function() { | |
| return this.store.findRecord('user', 1); | |
| }, | |
| conditionError: function() { | |
| return "hello"; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Helper.extend({ | |
| compute(params, {attribute}) { | |
| const model = params[0]; | |
| return model.get('errors').errorsFor(attribute); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export function initialize() { | |
| // Returns books embedded in authors | |
| $.mockjax({ | |
| type: 'GET', | |
| url: '/users/1', | |
| status: 200, | |
| dataType: 'json', | |
| responseText: { | |
| user: { | |
| id: 1, | |
| email: "some invalid email" | |
| } | |
| } | |
| }); | |
| $.mockjax({ | |
| type: 'PUT', | |
| url: '/users/1', | |
| status: 422, | |
| dataType: 'json', | |
| responseText: { | |
| "errors": { | |
| "email": ["is invalid"], | |
| "name": ["is already being used"], | |
| "conditions": [{ | |
| "discountAmount": ["is wrong"] | |
| }] | |
| } | |
| } | |
| }); | |
| } | |
| export default { | |
| name: 'mockjax', | |
| initialize: initialize | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import DS from 'ember-data'; | |
| export default DS.Model.extend({ | |
| email: DS.attr() | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import DS from 'ember-data'; | |
| const ActiveModelSerializer = DS.ActiveModelSerializer; | |
| export default ActiveModelSerializer.extend(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "version": "0.4.13", | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.1/ember.debug.js", | |
| "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.16/ember-data.js", | |
| "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.1/ember-template-compiler.js", | |
| "active-model-adapter": "https://rawgit.com/ember-data/active-model-adapter-dist/master/active-model-adapter.js", | |
| "jquery-mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.3/jquery.mockjax.js" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment