From c3010a70e88b520d99ff19dd98b212b316a74012 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Mon, 13 Apr 2020 15:36:59 +0200 Subject: [PATCH] Adding Meals, WIP --- app/controllers/meals_controller.rb | 21 +++++++++++++++++++++ app/models/meal.rb | 0 app/models/measurement_routine.rb | 2 +- app/views/layouts/_sidebar.html.erb | 1 + config/locales/en.yml | 1 + config/routes.rb | 1 + init.rb | 2 ++ lib/body_tracking/project_patch.rb | 2 ++ 8 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/controllers/meals_controller.rb create mode 100644 app/models/meal.rb diff --git a/app/controllers/meals_controller.rb b/app/controllers/meals_controller.rb new file mode 100644 index 0000000..89ab654 --- /dev/null +++ b/app/controllers/meals_controller.rb @@ -0,0 +1,21 @@ +class MealsController < ApplicationController + layout 'body_tracking' + menu_item :body_trackers + helper :body_trackers + + include Concerns::Finders + + before_action :find_project_by_project_id, only: [:index, :new, :create] + before_action :find_meal, only: [:edit, :update, :destroy] + before_action :authorize + + def index + prepare_meals + end + + private + + def prepare_meals + @meals = @project.meals.includes(:ingredients) + end +end diff --git a/app/models/meal.rb b/app/models/meal.rb new file mode 100644 index 0000000..e69de29 diff --git a/app/models/measurement_routine.rb b/app/models/measurement_routine.rb index 28e0c3b..04f304a 100644 --- a/app/models/measurement_routine.rb +++ b/app/models/measurement_routine.rb @@ -4,7 +4,7 @@ class MeasurementRoutine < ActiveRecord::Base foreign_key: 'routine_id', dependent: :restrict_with_error, extend: BodyTracking::ItemsWithQuantities has_many :readout_columns, as: :column_view, dependent: :destroy, - class: 'QuantityColumn', extend: BodyTracking::TogglableColumns + class_name: 'QuantityColumn', extend: BodyTracking::TogglableColumns has_many :quantities, -> { order "lft" }, through: :readout_columns validates :name, presence: true, uniqueness: {scope: :project_id} diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index 452c6eb..214d2df 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -10,6 +10,7 @@

<%= t ".heading_diet" %>