Save method behaviour changed?

As an aside recent versions of rails raise
ActiveRecord::RecordNotUnique in
such cases, although this is a subclass of
so shouldn't change behaviour as far as you're concern. You're also
changing the signature of save although I don't think that is related
to the problem at hand.

On: Tue Mar 5, 2013 1:48 pm ((PST)), "Les Nightingill" lesnightingill wrote:

perhaps the exception being raised is not

suggest trying rescue with no exception specified to see if there is a
different exception being raised.


Bingo! Rails-3.2.12 implements code similar to that I was providing
in hll_ar_exception( this_exception ) ) and actually returns the
exact message from PG that I was checking for therein.

  def save( * )
      puts( "I go" )
      puts( "I return" )
    rescue => e
      puts( e.inspect )

Using the default profile...
.................I go
#<ActiveRecord::RecordNotUnique: PG::Error: ERROR: duplicate key
value violates unique constraint "idxu_currencies_currency_code"
DETAIL: Key (currency_code)=(JPY) already exists.
: INSERT INTO "currencies" ("changed_at", "changed_by", "created_at",
"created_by", "currency_code", "currency_name", "discount_factor",
"effective_from", "fx_accounting_factor", "fx_accounting_margin",
"is_payable", "is_receivable", "premium_factor", "superseded_after")
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)

(::slight_smile: failed steps (::slight_smile:

Mystery solved. Thanks.