To handle nil date_sale, add this on top of your model:
validate_presence_of :date_sale
To check if there is a buyer! = Seller, you could do
validate :buyer_is_not_seller
def buyer_is_not_seller
errors.add(:buyer, "shouldn't be seller") if buyer.id == seller.id
end
source
share