Skip to content

Instantly share code, notes, and snippets.

var TokenAuth = Ember.Object.extend({
accessToken: $.cookie('accessToken'),
serverTokenEndpoint: 'http://api.lvh.me:3000/oauth/token/',
init: function() {
if(this.isAuthenticated) {
DS.RESTAdapter.reopen({
headers: {
"Authorization": "Bearer " + this.accessToken
}
});
import TokenAuth from 'appkit/lib/token-auth';
export default {
name: "token-auth",
before: "store",
initialize: function(container, application) {
application.register('auth:main', TokenAuth);
application.inject('controller', 'auth', 'auth:main');
Recipe = DS.Model.extend
title: DS.attr('string')
steps: DS.hasMany('step', {async: true})
Step = DS.Model.extend
substeps: DS.hasMany('substep', {async: true})
Substep = DS.Model.extend()
class RecipeSerializer < ActiveModel::Serializer
embed :ids, include: true
has_many :steps
attributes :id, :title
end
<h1>{{title}}</h1>
<ul>
{{#each step in steps itemController='step'}}
<li>ID: {{step.id}}, Order: {{step.order}}</li>
<ul>
{{#each substep in step.substeps}}
<li>
<img {{bind-attr src=substep.image}} />
</li>
{{/each}}
class Recipe < ActiveRecord::Base
has_many :recipe_skills
has_many :skills, through: :recipe_skills
end
class Skill < ActiveRecord::Base
has_many :recipe_skills
has_many :recipes, through: :recipe_skills
end
{
"skills": [
{
"id": 1,
"name": "Grilling Chicken",
"earned": true
}
],
"ingredients": [
{
app.import({
development: 'vendor/ember-data/ember-data.js',
production: 'vendor/ember-data/ember-data.prod.js'
}, {
exports: {
'ember-data': [
'default'
]
}
});
{:TOTAL=>619142, :FREE=>319189, :T_OBJECT=>12954, :T_CLASS=>9719, :T_MODULE=>1393, :T_FLOAT=>9, :T_STRING=>135036, :T_REGEXP=>2297, :T_ARRAY=>48333, :T_HASH=>11471, :T_STRUCT=>492, :T_BIGNUM=>11, :T_FILE=>14, :T_DATA=>45136, :T_MATCH=>6, :T_COMPLEX=>1, :T_RATIONAL=>889, :T_NODE=>30082, :T_ICLASS=>2110}
{:count=>71, :heap_used=>1519, :heap_length=>2426, :heap_increment=>906, :heap_live_slot=>305930, :heap_free_slot=>313212, :heap_final_slot=>0, :heap_swept_slot=>156288, :heap_eden_page_length=>1135, :heap_tomb_page_length=>384, :total_allocated_object=>3314074, :total_freed_object=>3008144, :malloc_increase=>624, :malloc_limit=>16777216, :minor_gc_count=>34, :major_gc_count=>37, :remembered_shady_object=>8835, :remembered_shady_object_limit=>17670, :old_object=>288401, :old_object_limit=>576802, :oldmalloc_increase=>1008, :oldmalloc_limit=>16777216}
{:TOTAL=>619142, :FREE=>313165, :T_OBJECT=>14333, :T_CLASS=>9719, :T_MODULE=>1393, :T_FLOAT=>9, :T_STRING=>137354, :T_REGEXP=>2298, :T_ARRAY=>49077, :T_HASH=>12864