class TargetAllocation < ApplicationRecord belongs_to :target belongs_to :nutrient_profile validates :percentage, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 } validates :nutrient_profile_id, uniqueness: { scope: :target_id } end