Added nested nutrients in ingredient form
This commit is contained in:
@@ -4,6 +4,8 @@ class Ingredient < ActiveRecord::Base
|
||||
}
|
||||
|
||||
belongs_to :project
|
||||
has_many :nutrients
|
||||
accepts_nested_attributes_for :nutrients
|
||||
|
||||
validates :project, associated: true
|
||||
validates :name, presence: true, uniqueness: {scope: :project_id}
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
class Nutrient < ActiveRecord::Base
|
||||
belongs_to :ingredient
|
||||
|
||||
validates :ingredient, presence: true, associated: true
|
||||
validates :quantity, presence: true, associated: true
|
||||
validates :amount, numericality: {greater_than: 0}
|
||||
validates :unit, presence: true, associated: true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user