Forum: Ruby on Rails Conditional Validation: only if a record can be found

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Scott H. (Guest)
on 2009-05-23 20:55

I have a guestlist page which lists tickets and a user can attache a
guest to each ticket by using an auto complete form.

If each ticket has a guest attached, then the guestlist is 'full'

I have this rule in my controller and I want to turn it into a
validation in the model. Any ideas?

(sudo code)

if Ticket.find(first, condition => guestlist_id = ? and guest_id IS
    attach guest
    display 'guestlist is full'

Thanks for your help

This topic is locked and can not be replied to.