Updated Measurement to reflect ReadoutValue removal
This commit is contained in:
@@ -5,7 +5,7 @@ class Measurement < ActiveRecord::Base
|
||||
has_many :readouts, inverse_of: :measurement, dependent: :destroy, validate: true
|
||||
validates :readouts, presence: true
|
||||
accepts_nested_attributes_for :readouts, allow_destroy: true, reject_if: proc { |attrs|
|
||||
attrs['quantity_id'].blank?
|
||||
attrs['quantity_id'].blank? && attrs['value'].blank?
|
||||
}
|
||||
# Readout (quantity_id, unit_id) pair uniqueness check for nested attributes
|
||||
validate do
|
||||
@@ -15,7 +15,7 @@ class Measurement < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
validates :name, presence: true, uniqueness: {scope: :project_id}
|
||||
validates :name, presence: true
|
||||
|
||||
after_initialize do
|
||||
if new_record?
|
||||
|
||||
@@ -4,7 +4,7 @@ class Nutrient < ActiveRecord::Base
|
||||
belongs_to :unit, required: true
|
||||
|
||||
validates :quantity, uniqueness: {scope: :ingredient_id}
|
||||
validates :amount, numericality: {greater_thani_or_equal_to: 0.0}
|
||||
validates :amount, numericality: {greater_than_or_equal_to: 0.0}
|
||||
|
||||
after_initialize do
|
||||
if new_record?
|
||||
|
||||
@@ -4,4 +4,5 @@ class Readout < ActiveRecord::Base
|
||||
belongs_to :unit, required: true
|
||||
|
||||
validates :quantity, uniqueness: {scope: [:measurement_id, :unit_id]}
|
||||
validates :value, numericality: true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user