In the frontend ,i have a text box which accepts program id .If we gives
value in that , it will get stored in sql database, but before storing
i want to check whether the program id is exist in database. If exist
then we
instruct the user to give another program id. If not then ok to insert.
how can i validate this input?
In the frontend ,i have a text box which accepts program id .If we gives
value in that , it will get stored in sql database, but before storing
i want to check whether the program id is exist in database. If exist
then we
instruct the user to give another program id. If not then ok to insert.
how can i validate this input?
Use validates_uniqueness_of on the field, but also specify a unique
key constraint in the database in order to ensure that a duplicate
value cannot be saved, as validates_uniqueness_of can fail to detect
duplicate values due to race conditions.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.