1
0

Added Ingredient#destroy

This commit is contained in:
cryptogopher
2019-09-15 19:00:04 +02:00
parent 893e2646d0
commit 9878b42655
2 changed files with 16 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ class Ingredient < ActiveRecord::Base
belongs_to :project
belongs_to :ref_unit, class_name: 'Unit'
has_many :nutrients, inverse_of: :ingredient
has_many :nutrients, inverse_of: :ingredient, dependent: :destroy
accepts_nested_attributes_for :nutrients, allow_destroy: true, reject_if: proc { |attrs|
attrs['quantity_id'].blank? && attrs['amount'].blank?
}