-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Co-Lab-You-Belong-in-Tech/fix/dashboard
Fix/dashboard
- Loading branch information
Showing
84 changed files
with
1,265 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
class AvoidFoodCategoriesController < ApplicationController | ||
before_action :set_avoid_food_category, only: %i[show edit update destroy] | ||
|
||
# GET /avoid_food_categories or /avoid_food_categories.json | ||
def index | ||
@avoid_food_categories = AvoidFoodCategory.all | ||
end | ||
|
||
# GET /avoid_food_categories/1 or /avoid_food_categories/1.json | ||
def show; end | ||
|
||
# GET /avoid_food_categories/new | ||
def new | ||
@avoid_food_category = AvoidFoodCategory.new | ||
end | ||
|
||
# GET /avoid_food_categories/1/edit | ||
def edit; end | ||
|
||
# POST /avoid_food_categories or /avoid_food_categories.json | ||
def create | ||
@avoid_food_category = AvoidFoodCategory.new(avoid_food_category_params) | ||
|
||
respond_to do |format| | ||
if @avoid_food_category.save | ||
format.html do | ||
redirect_to avoid_food_category_url(@avoid_food_category), | ||
notice: t(:avoid_food_category_created) | ||
end | ||
format.json { render :show, status: :created, location: @avoid_food_category } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @avoid_food_category.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /avoid_food_categories/1 or /avoid_food_categories/1.json | ||
def update | ||
respond_to do |format| | ||
if @avoid_food_category.update(avoid_food_category_params) | ||
format.html do | ||
redirect_to avoid_food_category_url(@avoid_food_category), | ||
notice: t(:avoid_food_category_updated) | ||
end | ||
format.json { render :show, status: :ok, location: @avoid_food_category } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @avoid_food_category.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /avoid_food_categories/1 or /avoid_food_categories/1.json | ||
def destroy | ||
@avoid_food_category.destroy | ||
|
||
respond_to do |format| | ||
format.html do | ||
redirect_to avoid_food_categories_url, | ||
notice: t(:avoid_food_category_destroyed) | ||
end | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_avoid_food_category | ||
@avoid_food_category = AvoidFoodCategory.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def avoid_food_category_params | ||
params.require(:avoid_food_category).permit(:name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
class AvoidFoodsController < ApplicationController | ||
before_action :set_avoid_food, only: %i[show edit update destroy] | ||
|
||
# GET /avoid_foods or /avoid_foods.json | ||
def index | ||
@avoid_foods = AvoidFood.all | ||
end | ||
|
||
# GET /avoid_foods/1 or /avoid_foods/1.json | ||
def show; end | ||
|
||
# GET /avoid_foods/new | ||
def new | ||
@avoid_food = AvoidFood.new | ||
end | ||
|
||
# GET /avoid_foods/1/edit | ||
def edit; end | ||
|
||
# POST /avoid_foods or /avoid_foods.json | ||
def create | ||
@avoid_food = AvoidFood.new(avoid_food_params) | ||
|
||
respond_to do |format| | ||
if @avoid_food.save | ||
format.html { redirect_to avoid_food_url(@avoid_food), notice: t(:avoid_food_created) } | ||
format.json { render :show, status: :created, location: @avoid_food } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @avoid_food.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /avoid_foods/1 or /avoid_foods/1.json | ||
def update | ||
respond_to do |format| | ||
if @avoid_food.update(avoid_food_params) | ||
format.html { redirect_to avoid_food_url(@avoid_food), notice: t(:avoid_food_updated) } | ||
format.json { render :show, status: :ok, location: @avoid_food } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @avoid_food.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /avoid_foods/1 or /avoid_foods/1.json | ||
def destroy | ||
@avoid_food.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to avoid_foods_url, notice: t(:avoid_food_destroyed) } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_avoid_food | ||
@avoid_food = AvoidFood.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def avoid_food_params | ||
params.require(:avoid_food).permit(:name, :avoid_food_category_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
class CategoryIngredientsController < ApplicationController | ||
before_action :set_category_ingredient, only: %i[show edit update destroy] | ||
|
||
# GET /category_ingredients or /category_ingredients.json | ||
def index | ||
@category_ingredients = CategoryIngredient.all | ||
end | ||
|
||
# GET /category_ingredients/1 or /category_ingredients/1.json | ||
def show; end | ||
|
||
# GET /category_ingredients/new | ||
def new | ||
@category_ingredient = CategoryIngredient.new | ||
end | ||
|
||
# GET /category_ingredients/1/edit | ||
def edit; end | ||
|
||
# POST /category_ingredients or /category_ingredients.json | ||
def create | ||
@category_ingredient = CategoryIngredient.new(category_ingredient_params) | ||
|
||
respond_to do |format| | ||
if @category_ingredient.save | ||
format.html do | ||
redirect_to category_ingredient_url(@category_ingredient), notice: t(:category_ingredient_created) | ||
end | ||
format.json { render :show, status: :created, location: @category_ingredient } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @category_ingredient.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /category_ingredients/1 or /category_ingredients/1.json | ||
def update | ||
respond_to do |format| | ||
if @category_ingredient.update(category_ingredient_params) | ||
format.html do | ||
redirect_to category_ingredient_url(@category_ingredient), | ||
notice: t(:category_ingredient_updated) | ||
end | ||
format.json { render :show, status: :ok, location: @category_ingredient } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @category_ingredient.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /category_ingredients/1 or /category_ingredients/1.json | ||
def destroy | ||
@category_ingredient.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to category_ingredients_url, notice: t(:category_ingredient_destroyed) } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_category_ingredient | ||
@category_ingredient = CategoryIngredient.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def category_ingredient_params | ||
# params.fetch(:category_ingredient, {}) | ||
params.require(:category_ingredient).permit(:name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
class IngredientsController < ApplicationController | ||
before_action :set_ingredient, only: %i[show edit update destroy] | ||
|
||
# GET /ingredients or /ingredients.json | ||
def index | ||
@ingredients = Ingredient.all | ||
end | ||
|
||
# GET /ingredients/1 or /ingredients/1.json | ||
def show; end | ||
|
||
# GET /ingredients/new | ||
def new | ||
@ingredient = Ingredient.new | ||
end | ||
|
||
# GET /ingredients/1/edit | ||
def edit; end | ||
|
||
# POST /ingredients or /ingredients.json | ||
def create | ||
@ingredient = Ingredient.new(ingredient_params) | ||
|
||
respond_to do |format| | ||
if @ingredient.save | ||
format.html { redirect_to ingredient_url(@ingredient), notice: t(:ingredient_created) } | ||
format.json { render :show, status: :created, location: @ingredient } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @ingredient.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /ingredients/1 or /ingredients/1.json | ||
def update | ||
respond_to do |format| | ||
if @ingredient.update(ingredient_params) | ||
format.html { redirect_to ingredient_url(@ingredient), notice: t(:ingredient_updated) } | ||
format.json { render :show, status: :ok, location: @ingredient } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @ingredient.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /ingredients/1 or /ingredients/1.json | ||
def destroy | ||
@ingredient.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to ingredients_url, notice: t(:ingredient_destroyed) } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_ingredient | ||
@ingredient = Ingredient.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def ingredient_params | ||
# params.fetch(:ingredient, {name}) | ||
params.require(:ingredient).permit(:name, :category_ingredient_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AvoidFoodCategoriesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AvoidFoodsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CategoryIngredientsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module IngredientsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class AvoidFood < ApplicationRecord | ||
belongs_to :avoid_food_category | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class AvoidFoodCategory < ApplicationRecord | ||
has_many :avoid_food, dependent: :destroy | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class CategoryIngredient < ApplicationRecord | ||
has_many :ingredients, dependent: :nullify | ||
has_many :category_ingredient_meals, dependent: :destroy | ||
has_many :meals, through: :category_ingredient_meals | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class CategoryIngredientMeal < ApplicationRecord | ||
belongs_to :meal | ||
belongs_to :category_ingredient | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Ingredient < ApplicationRecord | ||
belongs_to :category_ingredient, optional: true | ||
has_many :ingredient_meals, dependent: :destroy | ||
has_many :meals, through: :ingredient_meals | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class IngredientMeal < ApplicationRecord | ||
belongs_to :meal | ||
belongs_to :ingredient | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/views/avoid_food_categories/_avoid_food_category.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div id="<%= dom_id avoid_food_category %>"> | ||
<p> | ||
<strong>Name:</strong> | ||
<%= avoid_food_category.name %> | ||
</p> | ||
|
||
</div> |
2 changes: 2 additions & 0 deletions
2
app/views/avoid_food_categories/_avoid_food_category.json.jbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! avoid_food_category, :id, :name, :created_at, :updated_at | ||
json.url avoid_food_category_url(avoid_food_category, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<%= form_with(model: avoid_food_category) do |form| %> | ||
<% if avoid_food_category.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(avoid_food_category.errors.count, "error") %> prohibited this avoid_food_category from being saved:</h2> | ||
|
||
<ul> | ||
<% avoid_food_category.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.label :name, style: "display: block" %> | ||
<%= form.text_field :name %> | ||
</div> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<h1>Editing avoid food category</h1> | ||
|
||
<%= render "form", avoid_food_category: @avoid_food_category %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this avoid food category", @avoid_food_category %> | | ||
<%= link_to "Back to avoid food categories", avoid_food_categories_path %> | ||
</div> |
Oops, something went wrong.