Replaced Quantity 'primary' attr with ColumnView model
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user