Method: ActiveRecord::PGExtensions::PostgreSQLAdapter#defer_constraints
- Defined in:
- lib/active_record/pg_extensions/postgresql_adapter.rb
permalink #defer_constraints(*constraints) ⇒ Object
defers constraints, yields to the caller, and then resets back to immediate note that the reset back to immediate is not in an ensure block, since any error thrown would likely mean the transaction is rolled back, and setting constraint checking back to immediate would also fail
24 25 26 27 28 |
# File 'lib/active_record/pg_extensions/postgresql_adapter.rb', line 24 def defer_constraints(*constraints) set_constraints(:deferred, *constraints) yield set_constraints(:immediate, *constraints) end |