This file was deleted.

This file was deleted.

@@ -1,7 +1,12 @@
class RecipeSerializer < ActiveModel::Serializer
attributes :description,
include Rails.application.routes.url_helpers

attributes :created_at,
:description,
:directions,
:links,
:title,
:updated_at,
:yields,
:yields_unit

@@ -11,8 +16,19 @@ class RecipeSerializer < ActiveModel::Serializer

def needs_ingredients
h = ActiveModel::SerializableResource.new(object.ingredients.rels).serializable_hash[:data]
h.map do |ni|
{ needs_ingredient: ni }
end

h.map { |ni| { needs_ingredient: ni } }
end

def links
{
influencing_recipes: influencing_recipes_api_recipe_url(object)
}
end

def concoction_type
return unless object.concoction_type

ActiveModel::SerializableResource.new(object.concoction_type).serializable_hash[:data]
end
end
@@ -37,4 +37,6 @@

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

routes.default_url_options[:host] = 'concoctify.dev'
end
@@ -1,7 +1,16 @@
require 'action_controller/metal/renderers'
require 'active_model/serializable_resource'

ActionController::Renderers.add(:json_api) do |content, options|
self.content_type ||= Mime[:json_api]
valid_options = options.each_with_object({}) do |(k, v), result|
result[k] = v if %i[include].include?(k)
end

ActiveModel::SerializableResource.new(content).serializable_hash.to_json
Rails.logger.debug "json_api options: #{options}"
Rails.logger.debug "json_api valid options: #{valid_options}"
Rails.logger.debug "content class: #{content.class}"
# ActiveModel::SerializableResource.new(content, valid_options).serializable_hash.to_json
# content.to_json
content
end
@@ -0,0 +1,3 @@
if Rails.env.development?
Byebug.start_server 'localhost', ENV.fetch("BYEBUG_SERVER_PORT", 1048).to_i
end
@@ -1,10 +1,19 @@
Rails.application.routes.draw do
root 'ember#index'

resources :ingredients, except: %i[edit]
resources :concoction_types, except: %i[edit]
resources :concoctions
resources :recipes, except: %i[edit]
namespace :api do
resources :ingredients, except: %i[edit]
resources :concoction_types, except: %i[edit]
resources :concoctions
resources :recipes, except: %i[edit] do
get :influencing_recipes, on: :member
end
end

mount EmberCLI::Engine => 'ember-tests' if Rails.env.development?

# Let ember handle all non-API routes
constraints format: 'html' do
match '(*url)', to: 'ember#index', via: %i[get post]
end
end
@@ -8,5 +8,6 @@ export default DS.JSONAPIAdapter.extend({
host: 'http://concoctify.dev',
pathForType: function(type) {
return `${Ember.String.underscore(type)}s`;
}
},
namespace: 'api'
});
@@ -1,12 +1,15 @@
import DS from 'ember-data';

export default DS.Model.extend({
title: DS.attr('string'),
createdAt: DS.attr('date'),
description: DS.attr('string'),
directions: DS.attr('string'),
title: DS.attr('string'),
updatedAt: DS.attr('date'),
yields: DS.attr('number'),
yieldsUnit: DS.attr('string'),

needsIngredient: DS.hasMany('needsIngredient'),
concoctionType: DS.belongsTo('concoctionType')
concoctionType: DS.belongsTo('concoctionType'),
influencingRecipes: DS.hasMany('recipe', { async: true }),
needsIngredients: DS.hasMany('needsIngredient')
});
@@ -6,9 +6,10 @@ var Router = Ember.Router.extend({
});

Router.map(function() {
this.route('ingredients');
this.route('concoction-types');
this.route('recipes');
this.route('list-ingredients', { path: '/ingredients' });
this.route('list-concoction-types', { path: '/concoction_types' });
this.route('list-recipes', { path: '/recipes' });
this.route('show-recipe', { path: '/recipes/:recipe_id' });
});

export default Router;
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Route.extend({
model(params) {
return this.store.findRecord('recipe', params.recipe_id);
}
});
@@ -1,7 +1,7 @@
<h2 id="title">Welcome to Ember</h2>

{{#link-to "ingredients"}}Ingredients{{/link-to}}
{{#link-to "concoction-types"}}Concoction Types{{/link-to}}
{{#link-to "recipes"}}Recipes{{/link-to}}
{{#link-to "list-ingredients"}}Ingredients{{/link-to}}
{{#link-to "list-concoction-types"}}Concoction Types{{/link-to}}
{{#link-to "list-recipes"}}Recipes{{/link-to}}

{{outlet}}
File renamed without changes.
File renamed without changes.
@@ -3,12 +3,10 @@
<table>
<tr>
<th>Title</th>
<th>Link</th>
</tr>
{{#each model as |recipe|}}
<tr>
<td>{{recipe.title}}</td>
<td>{{#link-to "recipe" recipe}}show{{/link-to}}</td>
<td>{{#link-to "show-recipe" recipe}}{{recipe.title}}{{/link-to}}</td>
</tr>
{{/each}}
</table>
@@ -0,0 +1,43 @@
<div class="row">
<h3>{{model.title}}</h3>

<div class="blog-post-meta">
<p>Created at: <time>{{model.createdAt}}</time></p>
<p>Updated at: <time>{{model.updatedAt}}</time></p>
</div>

<dl class="dl-horizontal six columns">
<dt><strong>Concoction Type</strong></dt>
<dd>
<p>
<!-- {{show-concoction-type concoctionType=model.concoctionType}} -->
{{model.concoctionType.name}}
</p>
</dd>

<dt><strong>Description</strong></dt>
<dd>{{model.description}}</dd>

<dt><strong>Yields</strong></dt>
<dd>
<p>{{model.yields}} {{model.yieldsUnit}}</p>
</dd>

<dt><strong>Directions</strong></dt>
<dd>{{model.directions}}</dd>

<dt><strong>Ingredients</strong></dt>
<dd>
<ol>

{{#each model.needsIngredients as |needsIngredient|}}
<li>
Name: {{needsIngredient.ingredient.name}}
quantity: {{needsIngredient.quantity}}
quantity unit: {{needsIngredient.quantityUnit}}
</li>
{{/each}}
</ol>
</dd>
</dl>
</div>
@@ -0,0 +1,26 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('show-component-type', 'Integration | Component | show component type', {
integration: true
});

test('it renders', function(assert) {
assert.expect(2);

// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });

this.render(hbs`{{show-component-type}}`);

assert.equal(this.$().text().trim(), '');

// Template block usage:
this.render(hbs`
{{#show-component-type}}
template block text
{{/show-component-type}}
`);

assert.equal(this.$().text().trim(), 'template block text');
});
@@ -0,0 +1,12 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('adapter:application', 'Unit | Adapter | application', {
// Specify the other units that are required for this test.
// needs: ['serializer:foo']
});

// Replace this with your real tests.
test('it exists', function(assert) {
var adapter = this.subject();
assert.ok(adapter);
});
@@ -0,0 +1,12 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('concoction-type', 'Unit | Model | concoction type', {
// Specify the other units that are required for this test.
needs: []
});

test('it exists', function(assert) {
var model = this.subject();
// var store = this.store();
assert.ok(!!model);
});
@@ -0,0 +1,12 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('ingredient', 'Unit | Model | ingredient', {
// Specify the other units that are required for this test.
needs: []
});

test('it exists', function(assert) {
var model = this.subject();
// var store = this.store();
assert.ok(!!model);
});
@@ -0,0 +1,12 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('recipe', 'Unit | Model | recipe', {
// Specify the other units that are required for this test.
needs: []
});

test('it exists', function(assert) {
var model = this.subject();
// var store = this.store();
assert.ok(!!model);
});
@@ -0,0 +1,11 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:concoction-types', 'Unit | Route | concoction types', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

test('it exists', function(assert) {
var route = this.subject();
assert.ok(route);
});
@@ -0,0 +1,11 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:ingredients', 'Unit | Route | ingredients', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

test('it exists', function(assert) {
var route = this.subject();
assert.ok(route);
});
@@ -0,0 +1,11 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:recipes', 'Unit | Route | recipes', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

test('it exists', function(assert) {
var route = this.subject();
assert.ok(route);
});