I'm looking for a short demo of rescuing a DB constraint violation.
This is a newby question; my ruby skills are weak.
validation in the model is cool but I want to have the safety-net of
on top of validation.
I ran a little experiment to see what Rails does when a DB blocks
DML to prevent a contstraint violation.
The browser shows a 500 Error.
The development log shows this:
Symbl Create (0.000000) PGError: ERROR: duplicate key violates unique
: INSERT INTO symbls ("name", "cname") VALUES('ORCL', 'oracle2')
SQL (0.000378) ROLLBACK
ActiveRecord::StatementInvalid (PGError: ERROR: duplicate key
violates unique constraint "symbl_name_unique"
Does anyone have a short demo of rescuing a DB constraint violation?
I'd like to send a friendly message to the end-user rather than a 500