Skip to content

Instantly share code, notes, and snippets.

Amiel Martin amiel

View GitHub Profile
View URL_PROPOSAL.md

urlTemplate Proposal

Summary

urlTemplate improves the extesibility of API endpoint urls in RESTAdapter.

Motivation

I think that Ember Data has a reputation for being hard to configure. I've often heard it recommended to design the server API around what Ember Data expects.

View in-some-controller.js
var controller = this;
var success = function(model) {
controller.transitionToRoute('...');
};
var failure = function(xhr) {
controller.get('model').rollback();
if (xhr.status == 400) {
controller.showError($.parseJSON(xhr.responseText).detail);
@amiel
amiel / serializers-application.coffee
Created Aug 6, 2014
Example serializer for supporting the lack of a root key
View serializers-application.coffee
ApplicationSerializer = DS.RESTSerializer.extend
extract: (store, type, payload, id, requestType) ->
newPayload = {}
newPayload[type.typeKey] = payload
@_super store, type, newPayload, id, requestType
serializeIntoHash: (hash, type, record, options) ->
Ember.merge hash, @serialize record, options
@amiel
amiel / 1-other-versions.txt
Last active Aug 29, 2015
Npm list in ember.js -- tests in browser are failing because {{FEATURES}} is not getting replaced in tests/ember_configuration.js
View 1-other-versions.txt
$ npm --version
1.3.21
$ ember --version
version: 0.0.37
View README.md

This works with Ember Data 1.0.0-beta.7+canary.b45e23ba, but not Ember Data 1.0.0-beta.8.2a68c63a.

normalizePayload now takes just a payload.

What is the new way to do this?

@amiel
amiel / admin_user_spec.rb
Created May 20, 2014
spec/features/admin_user_spec.rb
View admin_user_spec.rb
require 'spec_helper'
describe 'Users' do
fixtures :all
let(:user) { admin_users(:amiel) }
before { login_to_admin }
describe '#index' do
it 'renders without fail' do
visit '/admin/users'
@amiel
amiel / example.js
Created May 14, 2014
Example gist cursor misalignment.
View example.js
Object.create({ braces: { make: { it: { slightly: { worse: { each: { time: {} } } } } } } });
return { cursor: "is basically one character off here" };
@amiel
amiel / IDEAS.md
Created May 13, 2014
nested urls ideas
View IDEAS.md
@amiel
amiel / my-controller.js
Created May 8, 2014
ember-validators with server validation errors
View my-controller.js
MyController = Ember.Controller.extend({
actions: {
save: function() {
this.get('model').save().then(function() {
// Success, maybe transitionToRoute or whatever
}, function(xhr) {
// Oh noes, we had an error, maybe it's a validation error
if (xhr.status == 400) {
$.parseJSON(xhr.responseText).each(function(attribute, errors) {
this.get('errors').set(attribute, errors);
View digicolor.rb
#!/usr/bin/env ruby -rubygems
# :P
# exit
require 'digiusb/digiblink'
# TODO:
COLORS = {
'success' => 'green',
You can’t perform that action at this time.