From ffed63e0b3beb6499e89274d2a8a8f016f93c985 Mon Sep 17 00:00:00 2001 From: Dan Elbert Date: Wed, 12 Sep 2018 14:17:18 -0500 Subject: [PATCH] fixed --- app/controllers/ingredients_controller.rb | 2 +- app/controllers/recipes_controller.rb | 2 +- app/javascript/components/RecipeEdit.vue | 18 +++++++++++--- .../components/RecipeEditIngredientEditor.vue | 12 ++++++++-- app/javascript/components/RecipeShow.vue | 6 ++++- app/javascript/lib/Api.js | 1 + app/models/concerns/ingredient.rb | 24 ------------------- app/models/food.rb | 5 +++- app/models/recipe.rb | 24 +++++++++++++++---- app/views/recipes/_recipe.json.jbuilder | 2 +- config/application.rb | 2 ++ ...80912172758_add_is_ingredient_to_recipe.rb | 14 +++++++++++ db/schema.rb | 3 ++- spec/models/recipe_spec.rb | 24 +++++++++++++++++++ 14 files changed, 100 insertions(+), 39 deletions(-) delete mode 100644 app/models/concerns/ingredient.rb create mode 100644 db/migrate/20180912172758_add_is_ingredient_to_recipe.rb diff --git a/app/controllers/ingredients_controller.rb b/app/controllers/ingredients_controller.rb index 4f02103..91a5f30 100644 --- a/app/controllers/ingredients_controller.rb +++ b/app/controllers/ingredients_controller.rb @@ -2,7 +2,7 @@ class IngredientsController < ApplicationController def search @ingredients = Food.search(params[:query]).order(:name).to_a - @ingredients.concat(Recipe.search_by_name(params[:query]).order(:name).to_a) + @ingredients.concat(Recipe.is_ingredient.search_by_name(params[:query]).order(:name).to_a) @ingredients.sort { |a, b| a.name <=> b.name } end diff --git a/app/controllers/recipes_controller.rb b/app/controllers/recipes_controller.rb index 2be59a0..71526d3 100644 --- a/app/controllers/recipes_controller.rb +++ b/app/controllers/recipes_controller.rb @@ -86,7 +86,7 @@ class RecipesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def recipe_params - params.require(:recipe).permit(:name, :description, :source, :yields, :total_time, :active_time, :step_text, tag_names: [], recipe_ingredients_attributes: [:name, :ingredient_id, :quantity, :units, :preparation, :sort_order, :id, :_destroy]) + params.require(:recipe).permit(:name, :description, :source, :yields, :total_time, :active_time, :step_text, :is_ingredient, tag_names: [], recipe_ingredients_attributes: [:name, :ingredient_id, :quantity, :units, :preparation, :sort_order, :id, :_destroy]) end def criteria_params diff --git a/app/javascript/components/RecipeEdit.vue b/app/javascript/components/RecipeEdit.vue index 1ada677..64b8601 100644 --- a/app/javascript/components/RecipeEdit.vue +++ b/app/javascript/components/RecipeEdit.vue @@ -1,5 +1,5 @@