I have a product model from an unique product. So when a user bought this model nobody can buy it again and the seller can not the same person then the buyer.
When I will buy the product I call the method product.buy(buyer). But this method should make the model invalid when the buyer = seller and date.sale != nil. But this doesn't work. How can I fix it?
def buy(buyer)
if self.user != buyer
if self.date_sale.nil?
self.date_sale = Time.now
self.buyer = buyer
else
# self.errors.add(:buyer, "article bougth") # Dont't work
end
else
# self.errors.add(:buyer, "seller can not buyer") # Dont't work
end
end