Save method behaviour changed?

As an aside recent versions of rails raise
ActiveRecord::RecordNotUnique in
such cases, although this is a subclass of
ActiveRecord::StatementInvalid
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"
codehacker@comcast.net lesnightingill wrote:

perhaps the exception being raised is not
ActiveRecord::StatementInvalid.

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

Les

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( * )
    begin
      puts( "I go" )
      super
      puts( "I return" )
    rescue => e
      puts( e.inspect )
      false
    end
  end

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)
RETURNING "id">
..F-

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

Mystery solved. Thanks.