1
0

Added :meals and :compositions_ingredients tables

Changed Column -> QuantityColumn
Updated :ingredients table to handle recipes
This commit is contained in:
cryptogopher
2020-04-13 01:11:34 +02:00
parent dbb8bdc62e
commit ced06a25bc
6 changed files with 28 additions and 9 deletions

View File

@@ -1,7 +1,9 @@
class Ingredient < ActiveRecord::Base
enum group: {
other: 0,
meat: 1
dish: 1,
recipe: 2,
meat: 3
}
# Has to go before any 'dependent:' association

View File

@@ -3,9 +3,9 @@ class MeasurementRoutine < ActiveRecord::Base
has_many :measurements, -> { order "taken_at DESC" }, inverse_of: :routine,
foreign_key: 'routine_id', dependent: :restrict_with_error,
extend: BodyTracking::ItemsWithQuantities
has_many :columns, as: :column_view, dependent: :destroy,
extend: BodyTracking::TogglableColumns
has_many :quantities, -> { order "lft" }, through: :columns
has_many :readout_columns, as: :column_view, dependent: :destroy,
class: 'QuantityColumn', extend: BodyTracking::TogglableColumns
has_many :quantities, -> { order "lft" }, through: :readout_columns
validates :name, presence: true, uniqueness: {scope: :project_id}
end

View File

@@ -1,4 +1,4 @@
class Column < ActiveRecord::Base
class QuantityColumn < ActiveRecord::Base
belongs_to :column_view, polymorphic: true
belongs_to :quantity
end