I have this code in a working RoR-3.1 app:
save
Override AR save method to catch DBMS specific errors
such as uniqueness constraint violations
def save
super
rescue ActiveRecord::StatementInvalid => this_exception
errors.add( currency_code, hll_ar_exception( this_exception ) )
false
end
In RoR-3.2.12 this no longer works. Once I pass a save involving a
duplicate record it never returns to the calling method. For example:
def save
super
fail( " die die die " )
rescue ActiveRecord::StatementInvalid => this_exception
produces no output and does not throw an exception but in the log file I
see this none-the-less:
PG::Error: ERROR: duplicate key value violates unique constraint
“idxu_currencies_currency_code”
DETAIL: Key (currency_code)=(JPY) already exists.
How do I get the old behaviour back? Calling save! instead super does
not
change the outcome.