Adding Meals, WIP
This commit is contained in:
21
app/controllers/meals_controller.rb
Normal file
21
app/controllers/meals_controller.rb
Normal file
@@ -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
|
||||
0
app/models/meal.rb
Normal file
0
app/models/meal.rb
Normal file
@@ -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}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<h3><%= t ".heading_diet" %></h3>
|
||||
<ul>
|
||||
<li><%= link_to t(".link_meals"), project_meals_path(@project) %></li>
|
||||
<li>
|
||||
<%= link_to t(".link_ingredients"), project_ingredients_path(@project) %>
|
||||
/
|
||||
|
||||
Reference in New Issue
Block a user