1
0

Replaced Quantity 'primary' attr with ColumnView model

This commit is contained in:
cryptogopher
2019-12-14 23:56:36 +01:00
parent ccf26d1830
commit 0c0ca1d286
19 changed files with 91 additions and 65 deletions

View File

@@ -3,14 +3,16 @@ module BodyTracking
ApplicationController.class_eval do
private
# :find_* methods are called before :authorize,
# @project is required for :authorize to succeed
def find_quantity
@quantity = Quantity.find(params[:id])
def find_quantity(id = params[:id])
@quantity = Quantity.find(id)
@project = @quantity.project
rescue ActiveRecord::RecordNotFound
render_404
end
def find_quantity_by_quantity_id
find_quantity(params[:quantity_id])
end
end
end
end

View File

@@ -5,8 +5,13 @@ module BodyTracking
has_many :ingredients, -> { order "name" }, dependent: :destroy
has_many :sources, dependent: :destroy
has_many :column_views, dependent: :destroy
has_many :quantities, -> { order "lft" }, dependent: :destroy
has_many :units, dependent: :destroy
def nutrients_column_view
self.column_views.find_or_create_by(name: 'Nutrients', domain: :diet)
end
end
end
end