class MOdrFileProduct < ApplicationRecord belongs_to :m_odr_file belongs_to :m_odr_product belongs_to :m_odr_product_size #validates :qte, :presence => true, numericality: { greater_than: 0} before_save do if self.m_odr_product_size self.m_odr_product = self.m_odr_product_size.m_odr_product end end end