Forum: Ruby on Rails Best Practice: Validating and returning conflicting object

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nic W. (Guest)
on 2006-02-20 20:49
(Received via mailing list)
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
This topic is locked and can not be replied to.