1
0

Adding/deleting nutrients on ingredient form working

This commit is contained in:
cryptogopher
2019-09-14 19:15:56 +02:00
parent dd8c4f2cd1
commit faef248449
3 changed files with 33 additions and 23 deletions

View File

@@ -5,7 +5,7 @@ class Ingredient < ActiveRecord::Base
belongs_to :project
has_many :nutrients
accepts_nested_attributes_for :nutrients
accepts_nested_attributes_for :nutrients, allow_destroy: true
validates :project, associated: true
validates :name, presence: true, uniqueness: {scope: :project_id}