Nic Werner
2006-Feb-20 18:47 UTC
[Rails] Best Practice: Validating and returning conflicting object
Hi, I have validation that checks for uniquess, but when the user enters a non-unique attribute, I''d like to present *what* the existing object is: For example, if I specified an IP address for a Device, and that IP already exists for another Device, I''d like to display the attributes of the existing device to help the user out. Right now, it just gives the user the obvious ''IP Address already exists'', which isn''t too helpful to the end-user. Does anybody know how to do this in the Validation model? I tried using an observer field, and when there is a conflict, I just pop-up the information, but this doesn''t seem as clean. Eventually, my goal is to allow the user to select an action, such as Overwrite, or Cancel based on the information provided. -- - Nic