Skip to content

Instantly share code, notes, and snippets.

View brancusi's full-sized avatar
😍

Aram Zadikian brancusi

😍
View GitHub Profile
//This is in the appliation route:
setupController:function(controller, model) {
this._super(controller, model);
controller.set('itemCollection', this.filterable(['ingredient', 'recipe']));
},
//This doesn't work
filterable:function(types){
return this.store.find('item').then(function(collection){
filterable:function(types){
var promise = this.store.find('item').then(function(collection){
return collection.filter(function(item){
return types.contains(item.get('typeTag'));
});
});
return DS.PromiseArray.create({promise:promise});
},
Ember.$.ajax({
url: 'https://something.com/api',
type: "POST",
dataType: 'jsonp',
jsonpCallback: 'handleResult',
data: {
"name": "Joe",
"date": "2013/11/20"
}
});
@brancusi
brancusi / gist:4c1c65f722070c1066ca
Created May 16, 2014 15:09
Ember - server/index.js
var express = require('express');
var bodyParser = require('body-parser');
var globSync = require('glob').sync;
var routes = globSync('./routes/*.js', { cwd: __dirname }).map(require);
var httpProxy = require('http-proxy');
var apiProxy = httpProxy.createProxyServer();
module.exports = function(emberCLIMiddleware) {
//Have tried using namespace or host
export default DS.ActiveModelAdapter.extend({
// host: 'api',
namespace: 'api',
headers: {
'api_key': 'o8ah28ohoa29o9h',
'email': 'me@nowhere.com'
}
});
export default DS.RESTSerializer.extend({
serialize: function(plan, options) {
var json = {
"name": "testing1",
"date": "2015/05/14",
"distance_unit": "mi"
}
return json;
}
import Ember from 'ember';
export default Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, {
setupController:function(controller, model) {
this.productStockCollection().then(function(collection){
controller.set('productStockCollection', collection);
});
Router.map(function() {
this.route('application');
this.route('protected');
this.route('login');
this.resource('clients', function(){
this.route('index', {path:'/'});
import DS from 'ember-data';
var attr = DS.attr,
hasMany = DS.hasMany,
belongsTo = DS.belongsTo;
export default DS.Model.extend({
isVirgin:true,
model:function(params){
return this.store.find('tvshow', params.anime_slug).then(function(result){
result.set('isVirgin', false);
return result;
});
}