Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

ActiveRecord::StatementInvalid when saving with association #8

@n00ge

Description

@n00ge

I'm getting an error while using this gem when saving a model with built associations.

#<ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block

An example would be:

user = User.new(some: attrs)
user.build_profile(some: attrs)
user.save

(not real but communicating the scenario of a has_one being built)

rescue_unique_constraint is on both the association (profile) and primary model (user) but the failure in this scenario is stemmed from the uniqueness failure on the association (profile).

Has anybody ran into this before? Any suggestions?

Wondering if the rescue in the gem for the unique constraint should also re-raise with ActiveRecord::Rollback if ActiveRecord::Base.connection.open_transactions.positive? is true?

This might be related?
jeremyevans/sequel#908

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions