Checking rails form data against key before saving to database -
i'm attempting write app allows users register different id numbers account through use of form. ids have own model , table follows:
mysql> show columns in hp_ids; +------------+--------------+------+-----+---------+----------------+ | field | type | null | key | default | | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | no | pri | null | auto_increment | | id_string | varchar(255) | yes | | null | | | pin_number | int(11) | yes | | null | | | user_id | int(11) | yes | mul | null | | | created_at | datetime | yes | | null | | | updated_at | datetime | yes | | null | | +------------+--------------+------+-----+---------+----------------+
the id number saved under id_string
the trick that, in order register id, user must enter corresponding pin prove have right register it..
what want is, each time attempts register new id/pin combination, check against key of sorts make sure have right combination. figure create new model called idkey
or can't figure out how tell controller check form values against second model prior saving them.
could point me in right direction?
it sounds conditional or custom validation.
i may misunderstanding question, pin_number
preexisting value? if so, i'd guess should exist in different table (which queried during custom validation).
Comments
Post a Comment