class PShipBillLine < ApplicationRecord belongs_to :p_ship_bill validates :qte, :presence => true validates :price, :presence => true before_validation do self.a_ok_total = self.qte.to_f * self.price.to_f end end