Forum: Ruby on Rails Best way to validate these dropdowns/multiselect options

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.
A5aa88cb70b8afb8511b1e77dd57964f?d=identicon&s=25 Andy Churchstone (andy)
on 2006-05-28 21:42
Hi,

I have a <form> page in which there are a number of dropdowns and
multi-selects, each of which is populated upon the page loading by
quering its own table with the most recent values. These other tables
are very simple two-column set-ups - one for the ID/value and another
for the verbose description.

I am getting the editing/creation stuff working fine. The dropdowns work
with a belongs_to/has_many relationship, while the multi-selects work on
a habtm/habtm relationship.

However, I now want to validate these selected options in the dropdowns
and multiselects (in a way akin to standard model validations so that
the new/edit page reloads with the submitted data and error messages).
By validating these I mean that each option will be checked to see if
that option actually exists in the database or else it will not save the
record. Obviously want to protect against someone submitting
malicious/incorrect data (eg. with non-existent values) through their
own forms they have copied and customised.

Thanks
This topic is locked and can not be replied to.