Is there any way to make the model execute an error message like flash[:notice]
??
I want to avoid entering the same data to my database twice..
before_save :no_duplication
private
def no_duplication
if CarPrice.where(:car_id => self.car_id).where(:agent_id => self.agent_id).blank?
return true
else
return false
end
end
This code stop duplicating but it doesn't send any error messages. How can I fix that??