1
0

Added ingredient index and form

This commit is contained in:
cryptogopher
2019-09-13 14:48:43 +02:00
parent c916e7fd3c
commit c82f903360
9 changed files with 77 additions and 22 deletions

View File

@@ -1,2 +1,13 @@
class Ingredient < ActiveRecord::Base
enum group: {
meat: 0
}
belongs_to :project
validates :project, associated: true
validates :name, presence: true, uniqueness: {scope: :project_id}
validates :ref_amount, numericality: {greater_than: 0}
validates :ref_unit, presence: true, associated: true
validates :group, inclusion: {in: groups.keys}
end