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.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/Y7fK11QRzwYJ.
For more options, visit https://groups.google.com/groups/opt_out.